# Ticket

## Fetch Tickets

<mark style="color:blue;">`GET`</mark> `https://app.clubcollect.com/api/v2/invoices/:id/tickets`

#### Path Parameters

| Name                                 | Type   | Description                                         |
| ------------------------------------ | ------ | --------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | ID of Invoice for which Tickets wish to be fetched. |

#### Query Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| api:key | string | Partner API Key (Deprecated) |

#### Headers

| Name                                            | Type   | Description                 |
| ----------------------------------------------- | ------ | --------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | ApiKey \<api\_key>          |
| Content-Type<mark style="color:red;">\*</mark>  | string | Must be `application/json`. |

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

```javascript
"tickets": [
  {
   "ticket_id": "...",
   "message": "I don't want to pay",
   "sender": "CUSTOMER",
   "date": "..."
  },
  {
   "ticket_id": "...",
   "message": "Please pay before the 30th",
   "sender": "COMPANY",
   "date": "..."
   }
]
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "error": "invalid_invoice_id"
}
```

{% endtab %}
{% endtabs %}

## Create Ticket

<mark style="color:green;">`POST`</mark> `https://app.clubcollect.com/api/v2/invoices/:id/tickets`

Create a support Ticket for an Invoice.

#### Path Parameters

| Name                                 | Type   | Description                                                |
| ------------------------------------ | ------ | ---------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | ID for the Invoice to which the Ticket should be attached. |

#### Query Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| api:key | string | Partner API Key (Deprecated) |

#### Headers

| Name                                            | Type   | Description                 |
| ----------------------------------------------- | ------ | --------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | ApiKey \<api\_key>          |
| Content-Type<mark style="color:red;">\*</mark>  | string | Must be `application/json`. |

#### Request Body

| Name                                      | Type   | Description             |
| ----------------------------------------- | ------ | ----------------------- |
| message<mark style="color:red;">\*</mark> | string | Contents of the Ticket. |

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

```javascript
{
  "ticket_id": "...",
  "message": "Please pay before the 30th",
  "sender": "COMPANY",
  "date": "..."
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "error": "invalid_invoice_id"
}
```

{% endtab %}

{% tab title="422 " %}

```javascript
{
  "error": "invalid_message"
}
```

{% endtab %}
{% endtabs %}

## Archive Ticket

<mark style="color:green;">`POST`</mark> `https://app.clubcollect.com/api/v2/invoices/:id/tickets/actions/archive`

Archive all Tickets for an Invoice.

#### Path Parameters

| Name                                 | Type   | Description                                             |
| ------------------------------------ | ------ | ------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | ID of the Invoice for which Tickets should be archived. |

#### Query Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| api:key | string | Partner API Key (Deprecated) |

#### Headers

| Name                                            | Type   | Description                 |
| ----------------------------------------------- | ------ | --------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | ApiKey \<api\_key>          |
| Content-Type<mark style="color:red;">\*</mark>  | string | Must be `application/json`. |

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

```
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "error": "invalid_invoice_id"
}
```

{% endtab %}
{% endtabs %}

## Assign Ticket to Support

<mark style="color:green;">`POST`</mark> `https://app.clubcollect.com/api/v2/invoices/:id/tickets/actions/assign:to:support`

Assign Tickets for an Invoice to ClubCollect Support Team.

#### Path Parameters

| Name                                 | Type   | Description                                                    |
| ------------------------------------ | ------ | -------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | ID of Invoice for which Tickets should be assigned to Support. |

#### Query Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| api:key | string | Partner API Key (Deprecated) |

#### Headers

| Name                                            | Type   | Description                 |
| ----------------------------------------------- | ------ | --------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | ApiKey \<api\_key>          |
| Content-Type<mark style="color:red;">\*</mark>  | string | Must be `application/json`. |

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

```
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "error": "invalid_invoice_id"
}
```

{% endtab %}
{% endtabs %}

## Fetch All Tickets

<mark style="color:blue;">`GET`</mark> `https://app.clubcollect.com/api/v2/companies/:id/tickets/:status`

Returns the list of tickets linked to a company, filtered by Ticket status, paginated and sorted in ascending order, i.e. from oldest to newest.

#### Path Parameters

| Name                                     | Type   | Description                                        |
| ---------------------------------------- | ------ | -------------------------------------------------- |
| status<mark style="color:red;">\*</mark> | string | One of: `{ unanswered answered archived }`         |
| id<mark style="color:red;">\*</mark>     | string | ID of Company for which Tickets should be fetched. |

#### Query Parameters

| Name        | Type    | Description                                                                                        |
| ----------- | ------- | -------------------------------------------------------------------------------------------------- |
| api:key     | string  | Partner API Key (Deprecated)                                                                       |
| page:number | integer | Page number. If it's not given, default to `1`.                                                    |
| page:size   | integer | Number of results per page. If it's not given, defaults to `30`. Maximum permitted value is `100`. |

#### Headers

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| Authorization<mark style="color:red;">\*</mark> | string | ApiKey \<api\_key> |

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

```javascript
"tickets": [
  {
   "invoice_id": "...",
   "ticket_id": "...",
   "message": "I don't want to pay",
   "sender": "CUSTOMER",
   "date": "..."
  },
  {
   "invoice_id": "...",
   "ticket_id": "...",
   "message": "Please pay before the 30th",
   "sender": "COMPANY",
   "date": "..."
   }
]
"page": {
  "page_number": 1,
  "page_size": 12,
  "total_entries": 53,
  "total_pages": 5
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "error": "not_found"
}
```

{% endtab %}

{% tab title="422 " %}

```javascript
{
  "error": "invalid_action"
}
```

{% endtab %}
{% endtabs %}
