> For the complete documentation index, see [llms.txt](https://dev.kapture.cx/kapture-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.kapture.cx/kapture-api/reference/api-reference/get-ticket-api.md).

# Get Ticket API

The Get Ticket API section allows users to get the existing ticket information sourced from external systems. Through this ,users can seamlessly fetch the details against the ticket by the ticket id.

## Get Ticket.

<mark style="color:green;">`POST`</mark> [https://](https://devapi.kapturecrm.com/search-ticket-by-ticket-id.html/v.2.0)[\<sub domain>](https://devapi.kapturecrm.com/add-ticket-from-other-source.html/v.2.0)[.kapturecrm.com/search-ticket-by-ticket-id.html/v.2.0](https://devapi.kapturecrm.com/search-ticket-by-ticket-id.html/v.2.0)

{% hint style="info" %}

```
NOTE: Please replace with your sub domain name in the API.
```

{% endhint %}

### Authentication:

To access this API endpoint, you need to include your API key in the request headers. For authentication, use the following header:

```
Basic <Your Token>
```

### Request Body

The request body should be a JSON object containing the details of the ticket to be fetched. Here are the  list of parameters.

<table><thead><tr><th>Name</th><th width="125">Mandatory</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>ticket_id</td><td>Yes</td><td>string</td><td>Ticket id to fetch the details for, if multiple please put comma separated</td></tr></tbody></table>

{% tabs %}
{% tab title="Body Request" %}

```json
{
    "ticket_ids": "713516551148",
    "conversation_type": "",
    "history_type": "",
    "assigned": "",
    "disposed": "",
    "response": "",
    "landing_queue": "",
    "create": "",
    "resolved": "",
    "include_emailbody": ""
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Please map in the request body if there's any extra associate body according to your use case.**
{% endhint %}

### Response Body

The API responds with a JSON object containing the details of the fetched ticket. If successful, the response will include the ticket ID and the other updated  relevant information.

| Response                                                      | Response Messages                                                                   |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| { ..., "status": "success"}                                   | Ticket fetched successfully.                                                        |
| {"message": "Invalid Auth Key","status": "failed"}            | Authorization key is either not passed in header, or incorrect, or expired/disabled |
| { "message": "Invalid Json.", "status": "failed" }            | Most probably, data may in array format. It should be in object format.             |
| { "message": "ticket\_ids are missing.", "status": "failed" } | Either ticket\_ids field is missing or empty.                                       |

{% tabs %}
{% tab title="Response" %}

```json
[
    {
        "additional_info": {},
        "history": {},
        "task_details": {
            "date": "19-04-2024 14:19",
            "tat": "",
            "sla": "",
            "status": "Pending",
            "nextFollowUp": "19-04-2024 14:19",
            "lastFollowUp": "22-04-2024 14:31",
            "taskId": 530348198,
            "email": "",
            "phone": "",
            "lastSource": "Mobile App",
            "lastConvesationTime": "19-04-2024 14:19",
            "title": "TEST 1",
            "orderId": "",
            "primarySource": "Mobile App",
            "ticketEmail": "",
            "folderId": 0,
            "ticketId": "713516551148",
            "detail": "",
            "mergedTicketId": "",
            "contactId": 0,
            "productId": 0,
            "creatorId": 209803,
            "customerId": 0,
            "assignedId": 209803,
            "creatorName": "Kapture Dev API&apos;s",
            "priority": "low",
            "attachment": "",
            "pendingTaskId": 0,
            "ticketCloseEmpId": 209803,
            "assignedToName": "Kapture Dev API&apos;s",
            "callBack": "",
            "queueKey": "",
            "customer_rating": 0,
            "lastConversationId": 0,
            "slaStatus": "out of sla",
            "queueName": "",
            "total_conversations": 0,
            "disposition": "Inbox",
            "taskEnddate": "",
            "customer_feedback": "",
            "url": "https://devapi.kapturecrm.com/employee/view-task-detail.html?detail=5/530348198/713516551148",
            "substatus": "Pending",
            "substatusKey": "PS",
            "assigneeCode": "",
            "ftr": "no",
            "attachments": []
        }
    }
]
```

{% endtab %}
{% endtabs %}

### Error Codes

| Error Codes | Description                                      |
| ----------- | ------------------------------------------------ |
| 400         | Bad Request - Invalid parameters or missing data |
| 401         | Unauthorized - Invalid or missing API key        |
| 403         | Forbidden - Insufficient permissions             |
| 404         | Not Found - Resource or endpoint not found       |
| 500         | Internal Server Error - Server-side issue        |

### Example of a working curl

{% tabs %}
{% tab title="cURL" %}

```json
curl --location 'https://devapi.kapturecrm.com/search-ticket-by-ticket-id.html/v.2.0' \
--header 'Authorization: Basic <Your Token>' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data '{
    "ticket_ids": "713516551148",
    "conversation_type": "",
    "history_type": "",
    "assigned": "",
    "disposed": "",
    "response": "",
    "landing_queue": "",
    "create": "",
    "resolved": "",
    "include_emailbody": ""
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import http.client
import json

conn = http.client.HTTPSConnection("devapi.kapturecrm.com")
payload = json.dumps({
  "ticket_ids": "713516551148",
  "conversation_type": "",
  "history_type": "",
  "assigned": "",
  "disposed": "",
  "response": "",
  "landing_queue": "",
  "create": "",
  "resolved": "",
  "include_emailbody": ""
})
headers = {
  'Authorization': 'Basic <Your Token>',
  'Content-Type': 'application/json',
  'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
}
conn.request("POST", "/search-ticket-by-ticket-id.html/v.2.0", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="Node.js" %}

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://devapi.kapturecrm.com/search-ticket-by-ticket-id.html/v.2.0',
  'headers': {
    'Authorization': 'Basic <Your Token>',
    'Content-Type': 'application/json',
    'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
  },
  body: JSON.stringify({
    "ticket_ids": "713516551148",
    "conversation_type": "",
    "history_type": "",
    "assigned": "",
    "disposed": "",
    "response": "",
    "landing_queue": "",
    "create": "",
    "resolved": "",
    "include_emailbody": ""
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}
{% endtabs %}
