# List Tickets

{% hint style="warning" %}
All API requests should contain [authorization headers](https://developers.socialboards.com/docs/apis/tickets/authorization-headers).
{% endhint %}

#### Request

```url
POST /tickets/list
```

#### Query Parameters.

This endpoint doesn't require query parameters.

#### Request Body

```json
{
    "categoryId": 33527,
    "customFields": [
        {
            "key": 18464,
            "value": "Option 2"
        }
    ],
    "from": "2020-01-01T00:00:00+00:00",
    "orderBy": "last_thread_activity_desc",
    "skip": 0,
    "source": "web",
    "status": "open",
    "take": 100,
    "to": "2020-03-02T00:00:00+00:00",
    "ticketIds": [
        4484636,
        4484618,
        4478963
    ]
}
```

Body of request should contain the following model serialized to JSON.

| Field        | Type                                                                                                                                    | Required | Comments                                                                                                                                                                              |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| categoryId   | nullabe integer                                                                                                                         | no       | Unique Id of category ticket should belong to. If value is `null` uncategorized tickets will be selected                                                                              |
| customFields | array of [Custom Field Id and Value](https://developers.socialboards.com/docs/apis/tickets/reference/objects/custom-field-value) models | no       | List of models containing custom field ids and values. If array contains several custom fields, tickets must have all of them to be selected in result                                |
| from         | string                                                                                                                                  | no       | Min creation time of tickets shown in results. string containing DateTime with offset, in the following format: "2020-02-27T12:28:02.6019432+01:00"                                   |
| orderBy      | string                                                                                                                                  | no       | Order of tickets in the list. Can be one of [TicketListOrderBy](https://developers.socialboards.com/docs/apis/tickets/reference/enumerations/ticket-list-order-by) enumeration values |
| skip         | integer                                                                                                                                 | no       | Amount of tickets should be skipped from the result                                                                                                                                   |
| source       | string                                                                                                                                  | no       | Source of tickets. Can be one of [TicketSource](https://developers.socialboards.com/docs/apis/tickets/reference/enumerations/ticket-source) enumeration values                        |
| status       | string                                                                                                                                  | no       | Ticket status. Can be one of [TicketStatus](https://developers.socialboards.com/docs/apis/tickets/reference/enumerations/ticket-status) enumeration values                            |
| take         | int                                                                                                                                     | no       | Max ammount of tickets shown in results. Max value is 50. default: 25                                                                                                                 |
| ticketIds    | array of integers                                                                                                                       | no       | ids of tickets to select from results. It can be used to fetch tickets by id(s)                                                                                                       |
| to           | string                                                                                                                                  | no       | Max creation time of tickets shown in results. string containing DateTime with offset, in the following format: "2020-02-27T12:28:02.6019432+01:00"                                   |

```json
{
    "data": [
        {
            "id": 4484636,
            "title": "New car price list.",
            "message": "Hello I want to buy a new car, how can I get a price list?",
            "htmlMessage": "Hello I want to buy a new car, how can I get a price list?",
            "attachments": [],
            "author": {
                "id": "7c0a344a-c369-4e27-9840-88257a56e835",
                "name": "Bill Smith",
                "image": null,
                "email": "bill_smith@gmail.com",
                "status": "client",
                "isBot": false
            },
            "category": {
                "id": 15597,
                "name": "Customers"
            },
            "creationTime": "2019-12-18T18:00:03.6368531+00:00",
            "customFields": [],
            "lastThreadElementCreationTime": "2019-12-18T18:00:03.6368531+00:00",
            "lockedBy": null,
            "originalLink": null,
            "properties": {
                "isAnonymized": false,
                "isMuted": false,
                "hasAttachments": true,
                "hasDraft": false,
                "isAssignedToBot": false,
                "isDeleted": false,
                "isExpired": true,
                "isHidden": false,
                "isLocked": false,
                "isSpam": false,
                "isSensitive": false
            },
            "replyCount": 0,
            "sentiment": "question",
            "source": "web",
            "detailedSource": "web_website",
            "sourceName": null,
            "status": "open",
            "tags": [
                "urgent"
            ]
        },
        {
            "id": 4484618,
            "title": "New car price list.",
            "message": "Hello I want to buy a new car, how can I get a price list?",
            "htmlMessage": "Hello I want to buy a new car, how can I get a price list?",
            "attachments": [],
            "author": {
                "id": "7c0a344a-c369-4e27-9840-88257a56e835",
                "name": "Bill Smith",
                "image": null,
                "email": "bill_smith@gmail.com",
                "status": "client",
                "isBot": false
            },
            "category": {
                "id": 15597,
                "name": "Customers"
            },
            "creationTime": "2019-12-18T17:55:52.6381081+00:00",
            "customFields": [],
            "lastThreadElementCreationTime": "2019-12-18T17:55:52.6381081+00:00",
            "lockedBy": null,
            "originalLink": null,
            "properties": {
                "isAnonymized": false,
                "isMuted": false,
                "hasAttachments": true,
                "hasDraft": false,
                "isAssignedToBot": false,
                "isDeleted": false,
                "isExpired": true,
                "isHidden": false,
                "isLocked": false,
                "isSpam": false,
                "isSensitive": false
            },
            "replyCount": 0,
            "sentiment": "question",
            "source": "web",
            "detailedSource": "web_website",
            "sourceName": null,
            "status": "open",
            "tags": []
        },
        {
            "id": 4478963,
            "title": "Cat is ill",
            "message": "I want to take my cat to a vet",
            "htmlMessage": "I want to take my cat to a vet",
            "attachments": [],
            "author": {
                "id": "35692164-bfaa-4c49-a23c-ecfa618f7d20",
                "name": "Robert Baker",
                "image": null,
                "email": "robert78baker@gmail.com",
                "status": "client",
                "isBot": false
            },
            "category": {
                "id": 15721,
                "name": "Other cases"
            },
            "creationTime": "2019-12-17T07:03:48.318717+00:00",
            "customFields": [],
            "lastThreadElementCreationTime": "2019-12-17T07:21:21.5003556+00:00",
            "lockedBy": null,
            "originalLink": null,
            "properties": {
                "isAnonymized": false,
                "isMuted": false,
                "hasAttachments": false,
                "hasDraft": false,
                "isAssignedToBot": false,
                "isDeleted": false,
                "isExpired": true,
                "isHidden": false,
                "isLocked": false,
                "isSpam": false,
                "isSensitive": false
            },
            "replyCount": 3,
            "sentiment": "question",
            "source": "web",
            "detailedSource": "web_website",
            "sourceName": null,
            "status": "open",
            "tags": []
        }
    ],
    "errorCode": -1,
    "errorText": null
}
```

`Data` field will contain an array of [Ticket](https://developers.socialboards.com/docs/apis/tickets/reference/objects/ticket) models.
