# تصدير التذاكر كاملة

GET /v1/ticket-exports — تصدير التذاكر كاملة

| الطريقة | المسار | الصلاحية | إجراء MCP |
| --- | --- | --- | --- |
| `GET` | `/v1/ticket-exports` | `tickets:read` | `export_tickets` |

## الوصف

Whole tickets, oldest change first, each in the import's own shape (`rabt.ticket_export` version 1): its fields, number, status and priority, classifications, tags, space, assignee, channel, contact and company (names, emails, phones in `related`), every item (messages with an email's HTML, notes, calls with transcript and a recording link, edits, reactions), system events, attachments with download links valid an hour, and the source ids it was imported by. A page's `data` is sent as is to another organization's `POST /v1/ticket-imports/{importId}/tickets` with `source: rabt` (its structure first). Start with `updated_since` (or nothing, for everything), then pass `next_cursor` until `end_of_stream`; later, the last `next_cursor` gives what changed since (a ticket comes again when its fields change or it gets an item, none is skipped, the last minute's changes wait; deleted tickets are left out). Up to 50 tickets a page, within one import call (1 MiB, 2,000 items): a larger ticket comes alone and is imported in parts, its items split. Owner and admins (`contacts.import_export` and `tickets.view_all`); a key or app needs `tickets:read` and `contacts:read`. Each page is in the sensitive-access log, and 1,000 tickets within an hour raise the large-export alert.

## الاعتماد

أرسل `Authorization: Bearer <key>` بمفتاح أو تطبيق OAuth يملك الصلاحية `tickets:read`. مفتاح الاختبار `rbk_test_…` يعمل على فضاء الاختبار دون أثر على العملاء.

## المعاملات

| الاسم | الموضع | النوع | مطلوب | الوصف |
| --- | --- | --- | --- | --- |
| `updated_since` | query | `string (date-time)` | لا | The first page: only tickets changed at or after this time (ISO 8601). Later pages carry on from `cursor`. |
| `channel_id` | query | `string (uuid)` | لا | Only the tickets of this connected channel (one number or mailbox). |
| `cursor` | query | `string` | لا | The `next_cursor` of the previous page (or of the last run, for later changes). |
| `limit` | query | `integer` | لا | Tickets per page (1 to 50, default 50). |
| `Rabt-Organization` | header | `string (uuid)` | لا | The organization the request acts in (its id). Needed with a session, and with a personal key or app that acts in several organizations (`API-8155`); it must be one of the credential's (`API-8105`). |

## الاستجابات

| الحالة | الوصف | المخطط |
| --- | --- | --- |
| `200` | A page of tickets. | `TicketExportPage` |
| `400` | `AUTH-1041`: no organization was named (send its id in the `Rabt-Organization` header). `API-8155`: the personal key or app acts in several organizations and the request named none. | `ProblemDetails` |
| `401` | `AUTH-1001`: not signed in, or the session has ended. `API-8101`: the API key or access token is not valid. | `ProblemDetails` |
| `403` | `AUTH-1040`: you are not a member of the organization named. `AUTH-1002`: your role lacks the `contacts.import_export` permission. `API-8102`: the API key or app lacks the `tickets:read` or `contacts:read` scope. `API-8105`: the `Rabt-Organization` header names an organization the API key or app does not act in. | `ProblemDetails` |
| `422` | `API-8001`: some fields are missing or not valid. `details.fields` lists each invalid field with its own code (e.g. `API-8002` required, `API-8012` wrong format). | `ProblemDetails` |
| `429` | `API-8004`: a rate limit quota is used up (see `RateLimit`). Try again after `Retry-After` seconds. | `ProblemDetails` |
| `default` | Any other error, with its code: e.g. `API-8005` the body is not valid JSON, `API-8006` the body is too large, `API-8007` the body is not JSON, `API-8008` no such endpoint, `API-8009` the request cannot be read, `API-8010` the request took too long, `API-8022` or `API-8023` the body compression or character set is not supported, `AUTH-1014` a change sent with the session cookie (or a sign-in) that does not come from a Rabt web page, `SYS-1002` or `SYS-1011` a dependency is unreachable, `SYS-1041` the organization is using its full share of the server, `SYS-1042` the server is overloaded (retry after `Retry-After`), `SYS-1070` Rabt is in read-only mode during an incident (changes are refused; reading works), `SYS-1071` a non-essential feature (search) is paused during an incident, `SYS-9000` an unexpected error. | `ProblemDetails` |

### مثال على الاستجابة (200)

```json
{
  "organization": {
    "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
    "name": "Layla"
  },
  "format": "rabt.ticket_export",
  "version": 1,
  "data": [
    {
      "format": "rabt.ticket_export",
      "version": 1,
      "external_id": "example",
      "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
      "number": 1,
      "subject": "Order 1042 has not arrived",
      "status": "open",
      "priority": "low",
      "channel": {
        "external_id": "example"
      },
      "source_channel": "example",
      "space": {
        "external_id": "example"
      },
      "assignee": {
        "external_id": "example"
      },
      "requester": {
        "external_id": "example"
      },
      "created_at": "2030-01-15T09:30:00.000Z",
      "updated_at": "2030-01-15T09:30:00.000Z",
      "closed_at": "2030-01-15T09:30:00.000Z",
      "tags": [
        {
          "name": "Layla"
        }
      ],
      "classifications": [
        {
          "list": "example",
          "option": "example"
        }
      ],
      "details": [
        {
          "name": "Layla",
          "value": "example"
        }
      ],
      "items": [
        {
          "external_id": "example",
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "kind": "message",
          "rabt_kind": "message",
          "direction": "inbound",
          "author": {
            "member": {
              "external_id": "example"
            }
          },
          "sender_type": "contact",
          "body": "Hello, how can we help?",
          "body_format": "text",
          "text": "Hello, how can we help?",
          "content_type": "text",
          "created_at": "2030-01-15T09:30:00.000Z",
          "channel_type": "example",
          "channel_id": "850b5911-b682-4cbb-aa86-49b381348440",
          "status": "example",
          "sent_at": "2030-01-15T09:30:00.000Z",
          "delivered_at": "2030-01-15T09:30:00.000Z",
          "read_at": "2030-01-15T09:30:00.000Z",
          "failed_at": "2030-01-15T09:30:00.000Z",
          "edited_at": "2030-01-15T09:30:00.000Z",
          "edits": [
            {
              "body": "Hello, how can we help?",
              "content_type": "example",
              "replaced_at": "2030-01-15T09:30:00.000Z"
            }
          ],
          "reactions": [
            {
              "by": "contact",
              "contact_id": "6d17dd3f-a837-4e3a-ad16-a563031b5b3a",
              "membership_id": "568f7457-b477-42d0-a368-fc32cd136eba",
              "emoji": "example",
              "reacted_at": "2030-01-15T09:30:00.000Z"
            }
          ],
          "attachments": [
            {
              "source_url": "https://example.com/path",
              "file_name": "Layla",
              "mime_type": "example",
              "size_bytes": 1,
              "content_id": "example"
            }
          ],
          "email": {
            "message_id": "example",
            "in_reply_to": "2030-01-15T09:30:00.000Z",
            "references": [
              "example"
            ]
          },
          "unavailable_attachments": [
            {
              "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
              "file_name": "Layla",
              "mime_type": "example",
              "size_bytes": 1,
              "code": "example"
            }
          ],
          "call": {
            "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
            "direction": "example",
            "status": "example",
            "from_number": "example",
            "to_number": "example",
            "membership_id": "568f7457-b477-42d0-a368-fc32cd136eba",
            "started_at": "2030-01-15T09:30:00.000Z",
            "answered_at": "2030-01-15T09:30:00.000Z",
            "ended_at": "2030-01-15T09:30:00.000Z",
            "duration_sec": 1,
            "end_reason": "example",
            "recording": {
              "url": "https://example.com/path",
              "expires_at": "2030-01-15T09:30:00.000Z"
            },
            "voicemail": {
              "url": "https://example.com/path",
              "expires_at": "2030-01-15T09:30:00.000Z",
              "duration_sec": 1
            },
            "transcript": [
              {
                "speaker": "example",
                "text": "Hello, how can we help?",
                "spoken_at": "2030-01-15T09:30:00.000Z"
              }
            ]
          },
          "import_refs": [
            {
              "source": "zendesk",
              "source_account": "example",
              "external_id": "example"
            }
          ]
        }
      ],
      "events": [
        {
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "created_at": "2030-01-15T09:30:00.000Z",
          "body": "Hello, how can we help?",
          "metadata": {
            "key": {}
          }
        }
      ],
      "kind": "private",
      "channel_type": "example",
      "note": "example",
      "close_reason": "member",
      "previous_ticket_id": "2606e8c9-6277-465f-a46a-022a521349fb",
      "merged_into_ticket_id": "42cd4e27-c58f-41c0-a04b-76f1641894f3",
      "spam_at": "2030-01-15T09:30:00.000Z",
      "ai_enabled": true,
      "related": {
        "channel": {
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "type": "example",
          "name": "Layla",
          "endpoint": "example"
        },
        "space": {
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "name": "Layla"
        },
        "members": [
          {
            "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
            "name": "Layla",
            "email": "customer@example.com"
          }
        ],
        "contact": {
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "name": "Layla",
          "erased": true,
          "emails": [
            "example"
          ],
          "phones": [
            "+15555550100"
          ]
        },
        "company": {
          "id": "53da65e0-3bd9-49fd-a91b-4767f12c95bc",
          "name": "Layla",
          "domains": [
            "example"
          ]
        }
      },
      "import_refs": [
        {
          "source": "zendesk",
          "source_account": "example",
          "external_id": "example"
        }
      ]
    }
  ],
  "next_cursor": "example",
  "end_of_stream": true
}
```

## الأخطاء

| الحالة | الأخطاء |
| --- | --- |
| `400` | [AUTH-1041](/errors/AUTH-1041), [API-8155](/errors/API-8155) |
| `401` | [AUTH-1001](/errors/AUTH-1001), [API-8101](/errors/API-8101) |
| `403` | [AUTH-1040](/errors/AUTH-1040), [AUTH-1002](/errors/AUTH-1002), [API-8102](/errors/API-8102), [API-8105](/errors/API-8105) |
| `422` | [API-8001](/errors/API-8001), [API-8002](/errors/API-8002), [API-8012](/errors/API-8012) |
| `429` | [API-8004](/errors/API-8004) |
| `default` | [API-8005](/errors/API-8005), [API-8006](/errors/API-8006), [API-8007](/errors/API-8007), [API-8008](/errors/API-8008), [API-8009](/errors/API-8009), [API-8010](/errors/API-8010), [API-8022](/errors/API-8022), [API-8023](/errors/API-8023), [AUTH-1014](/errors/AUTH-1014), [SYS-1002](/errors/SYS-1002), [SYS-1011](/errors/SYS-1011), [SYS-1041](/errors/SYS-1041), [SYS-1042](/errors/SYS-1042), [SYS-1070](/errors/SYS-1070), [SYS-1071](/errors/SYS-1071), [SYS-9000](/errors/SYS-9000) |

## استدعِها

```bash
curl -X GET 'https://api.rabt.systems/v1/ticket-exports' \
  -H "Authorization: Bearer $RABT_API_KEY"
```

## عبر MCP

الإجراء `export_tickets` هو نفس العملية بصلاحياتها وأخطائها (انظر [دليل MCP](/developers/docs/connect/mcp)).

```json
{
  "action": "export_tickets",
  "params": {}
}
```
