openapi: 3.0.0
info:
  title: Accounts Webhooks API
  version: "1.0.0"
  description: |
    API for handling account connection events via webhooks.
    The `accounts.added` webhook is sent when a user submits login credentials through Link. A new account object is created after the login credentials have undergone authentication, regardless of whether the connection was successful (`accounts.connected` is sent) or unsuccessful (`accounts.failed` is sent).

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 `accounts.connected` webhook is sent when a user's login credentials are successfully authenticated and the account connection was successful.

        <Warning>
        The webhook is also sent when a user re-connects an [existing account](/workflows/reconnecting-accounts).
        </Warning>
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountsConnectedRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountsConnectedWebhook'

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Username = api_key_id, Password = api_key_secret
  schemas:
    AccountsAddedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - accounts.added
          description: |
            Array containing the `accounts.added` event.
            Value: `accounts.added`
        name:
          type: string
          description: Your 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.
        secret:
          type: string
          description: Optional secret used to verify webhooks.
        config:
          type: object
          properties:
            include_resource:
              type: boolean
              description: |
                `"include_resource": true` will return the [account object](/api-reference/accounts#object) in the response within a `resource` object.
      required:
        - events
        - name
        - url
      example:
        events: ["accounts.added"]
        name: "name-for-the-webhook-subscription"
        url: "https://your-webhook-backend.com"
        secret: "optional-secret"
        config: { "include_resource": true }
    AccountsUpdatedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - accounts.updated
          description: |
            Array containing the `accounts.updated` event.
            Value: `accounts.updated`
        name:
          type: string
          description: Your 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.
        secret:
          type: string
          description: Optional secret used to verify webhooks.
        config:
          type: object
          properties:
            include_resource:
              type: boolean
              description: |
                `"include_resource": true` will return the [account object](/api-reference/accounts#object) in the response within a `resource` object.
      required:
        - events
        - name
        - url
      example:
        events: ["accounts.updated"]
        name: "name-for-the-webhook-subscription"
        url: "https://your-webhook-backend.com"
        secret: "optional-secret"
        config: { "include_resource": true }
    AccountsRemovedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - accounts.removed
          description: |
            Array containing the `accounts.removed` event.
            Value: `accounts.removed`
        name:
          type: string
          description: Your 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.
        secret:
          type: string
          description: Optional secret used to verify webhooks.
      required:
        - events
        - name
        - url
      example:
        events: ["accounts.removed"]
        name: "name-for-the-webhook-subscription"
        url: "https://your-webhook-backend.com"
        secret: "optional-secret"
    AccountsConnectedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - accounts.connected
          description: |
            Array containing the `accounts.connected` event.
            Value: `accounts.connected`
        name:
          type: string
          description: Your 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.
        secret:
          type: string
          description: Optional secret used to verify webhooks.
        config:
          type: object
          properties:
            include_resource:
              type: boolean
              description: |
                `"include_resource": true` will return the [account object](/api-reference/accounts#object) in the response within a `resource` object.
      required:
        - events
        - name
        - url
      example:
        events: ["accounts.connected"]
        name: "name-for-the-webhook-subscription"
        url: "https://your-webhook-backend.com"
        secret: "optional-secret"
        config: { "include_resource": true }
    AccountsFailedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
            enum:
              - accounts.failed
          description: |
            Array containing the `accounts.failed` event.
            Value: `accounts.failed`
        name:
          type: string
          description: Your 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.
        secret:
          type: string
          description: Optional secret used to verify webhooks.
        config:
          type: object
          properties:
            include_resource:
              type: boolean
              description: |
                `"include_resource": true` will return the [account object](/api-reference/accounts#object) in the response within a `resource` object.
      required:
        - events
        - name
        - url
      example:
        events: ["accounts.failed"]
        name: "name-for-the-webhook-subscription"
        url: "https://your-webhook-backend.com"
        secret: "optional-secret"
        config: { "include_resource": true }
    AccountsAddedWebhook:
      type: object
      properties:
        event:
          type: string
          description: The event that triggered the webhook.
          example: accounts.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"
            resource:
              type: object
              description: Optional account object.
      example:
        event: "accounts.added"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
    AccountsUpdatedWebhook:
      type: object
      properties:
        event:
          type: string
          description: The event that triggered the webhook.
          example: accounts.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"
            resource:
              type: object
              description: Optional account object.
      example:
        event: "accounts.updated"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
    AccountsRemovedWebhook:
      type: object
      properties:
        event:
          type: string
          description: The event that triggered the webhook.
          example: accounts.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"
      example:
        event: "accounts.removed"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
    AccountsConnectedWebhook:
      type: object
      properties:
        event:
          type: string
          description: The event that triggered the webhook.
          example: accounts.connected
        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"
            resource:
              type: object
              additionalProperties: true
              description: Optional [account object](/api-reference/accounts#object).
              properties:
                availability:
                  type: object
                  additionalProperties: true
                  description: Current data availability statuses for this account.
                  properties:
                    shifts:
                      type: object
                      nullable: true
                      additionalProperties: true
                      description: Shift data availability.
                    user_uploads:
                      type: object
                      nullable: true
                      additionalProperties: true
                      description: User upload availability.
      example:
        event: "accounts.connected"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
    AccountsFailedWebhook:
      type: object
      properties:
        event:
          type: string
          description: The event that triggered the webhook.
          example: accounts.failed
        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"
            error_code:
              type: string
              description: The [account connection error](/api-reference/account-connection-errors) that occurred.
              example: invalid_mfa
            error_message:
              type: string
              description: The account connection error message.
              example: "This user did not provide the correct multi-factor authentication response."
            resource:
              type: object
              description: Optional account object.
      example:
        event: "accounts.failed"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          error_code: "invalid_mfa"
          error_message: "This user did not provide the correct multi-factor authentication response."
