> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# webhooks المحادثات عبر API: الاشتراك في محادثة واحدة

> يشترك POST /v3/messages/conversations/{conversation_id}/webhooks/ في Didit بعنوان HTTPS لردود المحادثة وتحديثات حالتها وتغييرات الموافقة.

تتيح Conversation Webhooks API من Didit ربط endpoint يستخدم HTTPS بأحداث محادثة واحدة: `message.received` و`message.status.updated` و`contact.consent.updated`. وعند عدم تضمين `events` تُفعَّل الأحداث الثلاثة كلها.

يُوقَّع كل تسليم باستخدام `secret` الوارد في الاستجابة، وتُوضَع التوقيعة في الرأس `X-Signature-V2`، ولا يُعرض هذا السر إلا مرة واحدة.
استبدل `YOUR_PUBLIC_HOST` في المثال بمضيف HTTPS عام تملكه. يُرفض `url` الذي لا يستخدم HTTPS، أو الذي يشير إلى عنوان loopback أو عنوان خاص أو داخلي، ويُرجع الخطأ `invalid_url`، ويسري ذلك في البيئة التجريبية أيضاً.

يحتاج مفتاح API مقيّد النطاق إلى صلاحية الكتابة للرسائل وصلاحية القراءة للجلسات، وتسري عليه حدود سير العمل وحدود الجلسات المعتمدة فقط. أما المحادثة الواقعة خارج هذه الحدود، أو التي حُذفت جلستها، فتُرجع الاستجابة `404`.

```bash theme={null}
curl -X POST 'https://verification.didit.me/v3/messages/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90/webhooks/' \
  -H "x-api-key: $DIDIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://YOUR_PUBLIC_HOST/didit/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90", "events": ["message.received"]}'
```

لإيقاف التسليمات، [أزِل الاشتراك](https://docs.didit.me/ar/standalone-apis/messages-conversation-webhook-delete.md). واعثر على معرّف المحادثة عبر [قائمة المحادثات](https://docs.didit.me/ar/standalone-apis/messages-conversations-list.md).


## OpenAPI

````yaml ar/openapi-25.json POST /v3/messages/conversations/{conversation_id}/webhooks/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: Identity verification API. Authenticate with x-api-key header.
servers:
  - url: https://verification.didit.me
security: []
tags:
  - name: Bank Data
    description: >-
      Bank Link, connections, accounts, balances, transactions, institutions and
      coverage. One-time reads of real banks are open to live applications.
      Ongoing access with real banks is not open yet for live applications: it
      is available for sandbox applications with the Didit Test Bank, and opens
      country by country. Nothing is charged in sandbox. A call made with an API
      key needs a key that can reach Bank data: a full-access key can, and a
      scoped key needs `bank-data` in its scopes (read for reads, write for
      operations that change something). A scoped key without it is refused, and
      the call answers `403 bank_data_access_denied`. The account check is the
      exception: it needs write access to sessions, or full access, and not the
      Bank data scope. Raw bank data (accounts, balances, transactions and the
      change feed) also refuses a request that carries no API key.


      Every refusal under `/v3/bank/` except the account check's has the same
      JSON body (`code`, `message`, `request_id`, `field`, `next_action`,
      `retry_after`). A path that is not an operation, an id that is not a UUID
      or an unknown sub-resource answers `404 not_found` for every method, and
      any unexpected error answers `500 internal_error` with a `request_id`.
      Where Bank data is not available, every operation answers the platform's
      standard `404`, exactly as an unknown route does.
paths:
  /v3/messages/conversations/{conversation_id}/webhooks/:
    post:
      tags:
        - Messages
      summary: Subscribe a URL to one conversation's events
      description: >-
        Subscribe an HTTPS endpoint to one conversation's events:
        `message.received`, `message.status.updated` and
        `contact.consent.updated`, all three when `events` is left out. Every
        delivery is signed with `X-Signature-V2` using the returned `secret`,
        which this answer shows only once; other conversations keep their own
        subscriptions and endpoints.


        A scoped API key needs write access to messages. It also needs read
        access to sessions, and its workflow and approved-only session limits
        apply: a conversation outside them, or one whose session was deleted,
        answers 404 as another application's would.
      operationId: createMessageConversationWebhook
      parameters:
        - name: conversation_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            example: 6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90
          description: The conversation whose events the subscription carries.
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageConversationWebhookCreate'
            example:
              url: >-
                https://YOUR_PUBLIC_HOST/didit/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90
              events:
                - message.received
      responses:
        '201':
          description: The subscription, with its signing secret.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageConversationWebhook'
              example:
                webhook_id: b3e1d7a2-5c4f-4e8b-9d16-0a7c3f2e8b51
                secret: whsec_live_4d81
                events:
                  - message.received
        '400':
          description: >-
            `invalid_url`: `url` is not an HTTPS URL, or it points to a
            loopback, private or internal address, which no delivery is sent to,
            in sandbox too. An `events` value other than the three answers 400
            too, and the body names the field.
        '403':
          description: A scoped API key without write access to messages.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageAccessDenied'
        '404':
          description: >-
            No conversation with this id in your application, outside your key's
            session access, or whose session was deleted.
        '429':
          $ref: '#/components/responses/RateLimitedWrite'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X POST
            'https://verification.didit.me/v3/messages/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90/webhooks/'
            \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                  "url": "https://YOUR_PUBLIC_HOST/didit/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90",
                  "events": [
                    "message.received"
                  ]
                }'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Optional retry-safety key you choose for one operation, up to 255
        characters (a UUID works). A request repeated with the same key,
        endpoint, query and body is answered with the first response, same
        status and same body, and runs and bills nothing a second time. The same
        key with another endpoint, query or body returns `409`
        `idempotency_key_reused`, and while the first request is still running,
        `409` `idempotency_key_in_progress` with `Retry-After`. A failed request
        (any `4xx` or `5xx`) is not stored, so you can send it again with the
        same key. Keys belong to your application, whether you call with an API
        key or an access token. See [Retries and
        idempotency](/integration/api-errors#retries-and-idempotency).
      schema:
        type: string
        minLength: 1
        maxLength: 255
  schemas:
    MessageConversationWebhookCreate:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: >-
            A public HTTPS URL of your own that receives this conversation's
            events. Replace the placeholder in the examples with it: a URL that
            is not HTTPS, or that points to a loopback, private or internal
            address, answers `400 invalid_url`.
          maxLength: 2000
          example: >-
            https://YOUR_PUBLIC_HOST/didit/conversations/6f0c2a8e-3b1d-4c5e-9a7f-2d8b1e4c6a90
        events:
          type: array
          items:
            type: string
            enum:
              - message.received
              - message.status.updated
              - contact.consent.updated
          description: The events to deliver; left out, all three.
          minItems: 1
    MessageConversationWebhook:
      type: object
      required:
        - webhook_id
        - secret
        - events
      properties:
        webhook_id:
          type: string
          format: uuid
          description: The subscription; remove it with the delete call.
          example: b3e1d7a2-5c4f-4e8b-9d16-0a7c3f2e8b51
        secret:
          type: string
          description: >-
            The signing secret for this subscription's deliveries, shown only in
            this answer.
        events:
          type: array
          items:
            type: string
            enum:
              - message.received
              - message.status.updated
              - contact.consent.updated
          description: The events this subscription delivers.
    MessageAccessDenied:
      type: object
      description: 'A request the API key may not make: `detail` says why (no `code`).'
      required:
        - detail
      properties:
        detail:
          type: string
          example: This API key has no write access to messages.
    RateLimitBudgetError:
      type: object
      description: >-
        Returned only for a rate-limit middleware budget refusal. Other 429
        errors, including idempotency conflicts and endpoint-specific caps, do
        not promise these metadata fields.
      required:
        - detail
        - reference
        - limit
        - remaining
        - reset
        - window_seconds
      properties:
        detail:
          type: string
          description: Existing human-readable budget refusal message.
        reference:
          type: string
          pattern: ^RL-[0-9a-f]{32}$
          description: >-
            Opaque support reference: RL- followed by 32 lowercase UUID
            hexadecimal characters.
        limit:
          type: integer
          description: Budget for the exceeded scope; equals X-RateLimit-Limit.
        remaining:
          type: integer
          minimum: 0
          description: Remaining budget, clamped to zero; equals X-RateLimit-Remaining.
        reset:
          type: integer
          format: int64
          description: Window reset time in Unix seconds; equals X-RateLimit-Reset.
        window_seconds:
          type: integer
          description: >-
            Fixed-window duration in seconds, not the remaining wait. Honor
            Retry-After before retrying.
      example:
        detail: >-
          Write request rate limit exceeded. You can make up to 300 requests per
          minute.
        reference: RL-00000000000040008000000000000001
        limit: 300
        remaining: 0
        reset: 1794358860
        window_seconds: 60
  responses:
    RateLimitedWrite:
      description: >-
        The shared write limit of 300 requests per minute per API key was
        exceeded. Honor `Retry-After` before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitBudgetError'
          example:
            detail: >-
              Write request rate limit exceeded. You can make up to 300 requests
              per minute.
            reference: RL-00000000000040008000000000000001
            limit: 300
            remaining: 0
            reset: 1794358860
            window_seconds: 60
      headers:
        Retry-After:
          $ref: '#/components/headers/BudgetRetryAfter'
        X-RateLimit-Scope:
          $ref: '#/components/headers/BudgetXRateLimitScope'
        X-RateLimit-Limit:
          $ref: '#/components/headers/BudgetXRateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/BudgetXRateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/BudgetXRateLimitReset'
  headers:
    BudgetRetryAfter:
      description: >-
        Seconds to wait, rounded up to the next window. Present on middleware
        budget refusals.
      schema:
        type: integer
    BudgetXRateLimitScope:
      description: >-
        The scope whose budget was exceeded. Present on middleware budget
        refusals.
      schema:
        type: string
    BudgetXRateLimitLimit:
      description: >-
        Budget for the exceeded scope; equals body limit. Present on middleware
        budget refusals.
      schema:
        type: integer
    BudgetXRateLimitRemaining:
      description: >-
        Remaining budget, clamped to zero; equals body remaining. Present on
        middleware budget refusals.
      schema:
        type: integer
    BudgetXRateLimitReset:
      description: >-
        Reset time in Unix seconds; equals body reset. Present on middleware
        budget refusals.
      schema:
        type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your application's API key, from Developers -> API keys in the Business
        Console. The primary key has full access. A named key can be scoped:
        none, read or write per resource, limited to some workflows or to
        approved sessions, to a list of IP addresses, and to an expiry date. 401
        means the key is wrong, revoked or expired; 403 means no key was sent,
        the key has no access to this resource or action, or the request came
        from an address outside its IP list; 404 on a session route means the
        session is outside the key's workflows or statuses. A key without media
        access receives image, video and PDF URLs as null, and a key without
        sessions write receives session links and tokens as null. See
        https://docs.didit.me/console/api-keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.