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

# Add a webhook

> Post an agent's events to a URL, signed as Standard Webhooks describes. Adding the same URL again returns its webhook with the same secret.



## OpenAPI

````yaml /openapi.json post /agents/{id}/webhooks
openapi: 3.1.0
info:
  title: Artil API
  description: Give AI agents their own email inbox, SMS number and secret storage.
  version: 1.0.0
servers:
  - url: https://app.artil.dev/api
security:
  - token: []
paths:
  /agents/{id}/webhooks:
    post:
      tags:
        - Webhooks
      summary: Add a webhook
      description: >-
        Post an agent's events to a URL, signed as Standard Webhooks describes.
        Adding the same URL again returns its webhook with the same secret.
      operationId: addWebhook
      parameters:
        - in: path
          name: id
          required: true
          description: The agent's id
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  maxLength: 2000
                  format: uri
              required:
                - url
      responses:
        '201':
          description: The webhook and its secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookSetup'
        default:
          $ref: '#/components/responses/Failure'
components:
  schemas:
    WebhookSetup:
      type: object
      properties:
        id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        url:
          type: string
          format: uri
          description: Where Artil posts the agent's events
        deliveredAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        error:
          description: Why the last delivery failed
          type:
            - string
            - 'null'
        erroredAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        attempts:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
          description: How many times the event Artil is retrying has failed
        retryAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: When Artil next retries a failed event
        createdAt:
          type: string
          format: date-time
        secret:
          type: string
          description: The Standard Webhooks key each delivery is signed with
      required:
        - id
        - url
        - deliveredAt
        - error
        - erroredAt
        - attempts
        - retryAt
        - createdAt
        - secret
  responses:
    Failure:
      description: The request failed; the error says why
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - invalid_input
                      - unauthorized
                      - forbidden
                      - plan_limit
                      - not_found
                      - conflict
                      - rate_limited
                      - internal
                      - unavailable
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - error
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

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