openapi: 3.0.0
info:
  title: Vehicles Webhooks API
  version: "1.0.0"
  description: |
    API definition for Vehicles Webhooks.
    Sent when vehicles are added, updated, or removed.

servers:
  - url: https://api-sandbox.argyle.com
    description: Sandbox
  - url: https://api.argyle.com
    description: Production
security:
  - basicAuth: []

paths:
  /v2/webhooks:
    post:
      summary: Example subscription
      description: |
        The `vehicles.added` webhook is sent when a new vehicle object is added, either during an initial scan or when an account's data is [refreshed](/overview/ongoing-refresh).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VehiclesAddedRequest'
            examples:
              vehicles_added_subscription:
                summary: vehicles.added subscription
                value:
                  events:
                  - vehicles.added
                  name: name-for-the-webhook-subscription
                  url: https://your-webhook-backend.com
                  secret: optional-secret

      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VehiclesAddedWebhookMessage'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Username = api_key_id, Password = api_key_secret
  schemas:
    VehiclesAddedRequest:
      type: object
      properties:
        events:
          type: array
          description: "`vehicles.added`"
          items:
            type: string
          example: ["vehicles.added"]
        name:
          type: string
          description: "Your name for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        url:
          type: string
          description: Where you want to receive webhook delivery. This can be either a backend URL that you manage, or a URL provided by a webhook management service. Argyle handles URL encoding for webhook URLs. Send the URL in its normal, unencoded form.
          example: "https://your-webhook-backend.com"
        secret:
          type: string
          description: "Optional secret used to [verify webhooks](/api-guide/webhooks#verifying-webhooks)."
          example: "optional-secret"
      required:
        - events
        - name
        - url
      example:
        events:
        - vehicles.added
        name: name-for-the-webhook-subscription
        url: https://your-webhook-backend.com
        secret: optional-secret

    VehiclesUpdatedRequest:
      type: object
      properties:
        events:
          type: array
          description: "`vehicles.updated`"
          items:
            type: string
          example: ["vehicles.updated"]
        name:
          type: string
          description: "Your name for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        url:
          type: string
          description: Where you want to receive webhook delivery. This can be either a backend URL that you manage, or a URL provided by a webhook management service. Argyle handles URL encoding for webhook URLs. Send the URL in its normal, unencoded form.
          example: "https://your-webhook-backend.com"
        secret:
          type: string
          description: "Optional secret used to [verify webhooks](/api-guide/webhooks#verifying-webhooks)."
          example: "optional-secret"
      required:
        - events
        - name
        - url

    VehiclesRemovedRequest:
      type: object
      properties:
        events:
          type: array
          description: "`vehicles.removed`"
          items:
            type: string
          example: ["vehicles.removed"]
        name:
          type: string
          description: "Your name for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        url:
          type: string
          description: Where you want to receive webhook delivery. This can be either a backend URL that you manage, or a URL provided by a webhook management service. Argyle handles URL encoding for webhook URLs. Send the URL in its normal, unencoded form.
          example: "https://your-webhook-backend.com"
        secret:
          type: string
          description: "Optional secret used to [verify webhooks](/api-guide/webhooks#verifying-webhooks)."
          example: "optional-secret"
      required:
        - events
        - name
        - url

    VehiclesAddedWebhookMessage:
      type: object
      properties:
        event:
          type: string
          description: "`vehicles.added`"
          example: "vehicles.added"
        name:
          type: string
          description: "Name used for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        data:
          type: object
          properties:
            account:
              type: string
              format: uuid
              description: "ID of the account."
              example: "0187c66e-e7e5-811c-b006-2232f00f426a"
            user:
              type: string
              format: uuid
              description: "ID of the user."
              example: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
            vehicle:
              type: string
              format: uuid
              description: "ID of the [vehicle](/api-reference/vehicles#object)."
              example: "01763a69-5cbe-2edb-ade1-5591157c354d"

    VehiclesUpdatedWebhookMessage:
      type: object
      properties:
        event:
          type: string
          description: "`vehicles.updated`"
          example: "vehicles.updated"
        name:
          type: string
          description: "Name used for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        data:
          type: object
          properties:
            account:
              type: string
              format: uuid
              description: "ID of the account."
              example: "0187c66e-e7e5-811c-b006-2232f00f426a"
            user:
              type: string
              format: uuid
              description: "ID of the user."
              example: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
            vehicle:
              type: string
              format: uuid
              description: "ID of the [vehicle](/api-reference/vehicles#object)."
              example: "01763a69-5cbe-2edb-ade1-5591157c354d"

    VehiclesRemovedWebhookMessage:
      type: object
      properties:
        event:
          type: string
          description: "`vehicles.removed`"
          example: "vehicles.removed"
        name:
          type: string
          description: "Name used for the webhook subscription."
          example: "name-for-the-webhook-subscription"
        data:
          type: object
          properties:
            account:
              type: string
              format: uuid
              description: "ID of the account."
              example: "0187c66e-e7e5-811c-b006-2232f00f426a"
            user:
              type: string
              format: uuid
              description: "ID of the user."
              example: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
            vehicle:
              type: string
              format: uuid
              description: "ID of the removed [vehicle object](/api-reference/vehicles#object)."
              example: "01763a69-5cbe-2edb-ade1-5591157c354d"
