openapi: 3.0.0
info:
  title: Gigs Webhooks
  version: "1.0.0"
  description: |
    Sent when gigs are added, updated, or removed.

    If you need to access to gig data as soon as it is available:
    *   The `gigs.partially_synced` webhook is sent when gigs going back a specified number of days prior (starting from the date when the account was added) have been retrieved during initial data retrieval for a newly connected account.
    *   The `gigs.fully_synced` webhook is sent when all gigs have been retrieved during initial data retrieval for a newly connected account.

    Because some accounts can contain thousands of gigs, we recommend subscribing to the `gigs.partially_synced` webhook when especially time-sensitive. The `gigs.fully_synced` webhook will only be sent when all gig data has been retrieved, which may take up to several hours in these cases.

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 `gigs.removed` webhook is sent when a gig object has been deleted after a previous gig was not found when an account's data was refreshed.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GigsRemovedWebhookRequest'
            examples:
              gigs_removed_subscription:
                summary: gigs.removed subscription
                value:
                  events:
                  - gigs.removed
                  name: name-for-the-webhook-subscription
                  url: https://your-webhook-backend.com
                  secret: optional-secret
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GigsRemovedWebhookResponse'

  # /v2/webhooks:
  #   post:
  #     summary: Updated
  #     description: |
  #       ### Updated

  #       The `gigs.updated` webhook is sent when there is any change to a property value of the gig object.

  #       For example, after a gig assignment is completed the gig object's `status` value changes from `in_progress` to `completed`.
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/GigsUpdatedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Successful operation
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/GigsUpdatedWebhookResponse'
  # /v2/webhooks:
  #   post:
  #     summary: Removed
  #     description: |
  #       The `gigs.removed` webhook is sent when a gig object has been deleted after a previous gig was not found when an account's data was refreshed.
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/GigsRemovedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Successful operation
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/GigsRemovedWebhookResponse'
  # /v2/webhooks:
  #   post:
  #     summary: Partially Synced
  #     description: |
  #       The `gigs.partially_synced` webhook is sent when gigs going back a specified number of days prior (starting from the date when the account was added) have been retrieved. By default, this period is set to 30 days.

  #       <Info>You can subscribe to this webhook multiple times with different numbers of specified days.</Info>

  #       Of note:
  #       * This webhook is sent only during initial data retrieval (not ongoing refresh).
  #       * If the number of gigs for an account is small and captured completely with only one data pull, this webhook will not be sent. Instead the `gigs.fully_synced` webhook will be sent.
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/GigsPartiallySyncedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Successful operation
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/GigsPartiallySyncedWebhookResponse'
  # /v2/webhooks:
  #   post:
  #     summary: Fully Synced
  #     description: |
  #       The `gigs.fully_synced` webhook is sent when all gigs have been retrieved from a newly connected payroll account.
  #     requestBody:
  #       required: true
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/GigsFullySyncedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Successful operation
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/GigsFullySyncedWebhookResponse'

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Username = api_key_id, Password = api_key_secret
  schemas:
    GigsAddedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: |
            `gigs.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.
      required:
        - events
        - name
        - url
    GigsAddedResponse:
      type: object
      properties:
        event:
          type: string
          description: |
            `gigs.added`
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          description: ''
          properties:
            account:
              type: string
              format: uuid
              description: ID of the account.
            user:
              type: string
              format: uuid
              description: ID of the user.
            available_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the earliest available gig.
            available_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the most recent gig.
            available_count:
              type: integer
              description: Number of gigs currently available for this account.
            added_count:
              type: integer
              description: Number of gigs retrieved during a data refresh.
            added_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the earliest gig retrieved during a data refresh.
            added_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the most recent gig retrieved during a data refresh.
      example:
        event: "gigs.added"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          available_from: "2016-04-16T05:32:41Z"
          available_to: "2023-03-03T00:00:00Z"
          available_count: 2385
          added_count: 6
          added_from: "2023-03-02T00:00:00Z"
          added_to: "2023-03-03T00:00:00Z"
    GigsUpdatedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: |
            `gigs.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.
      required:
        - events
        - name
        - url
    GigsUpdatedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: |
            `gigs.updated`
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          description: ''
          properties:
            account:
              type: string
              format: uuid
              description: ID of the account.
            user:
              type: string
              format: uuid
              description: ID of the user.
            available_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's earliest available gig.
            available_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's most recent gig.
            available_count:
              type: integer
              description: Number of gigs currently available for this account.
            updated_count:
              type: integer
              description: Number of gigs updated.
            updated_gigs:
              type: array
              items:
                type: string
                format: uuid
              description: ID's of the updated gigs.
            updated_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the earliest updated gig.
            updated_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the most recent updated gig.
      example:
        event: "gigs.updated"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          available_from: "2016-04-16T05:32:41Z"
          available_to: "2023-03-03T00:00:00Z"
          available_count: 2385
          updated_count: 2
          updated_gigs:
            - "0187b43a-35fa-56e2-1a95-f7e4232a4b3a"
            - "0187dbfa-6f5e-a33a-af26-7e12ff408fea"
          updated_from: "2023-03-02T00:00:00Z"
          updated_to: "2023-03-03T00:00:00Z"
    GigsRemovedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: |
            `gigs.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](/api-guide/webhooks#verifying-webhooks).
      required:
        - events
        - name
        - url
      example:
        events:
        - gigs.removed
        name: name-for-the-webhook-subscription
        url: https://your-webhook-backend.com
        secret: optional-secret
    GigsRemovedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: |
            `gigs.removed`
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          description: ''
          properties:
            account:
              type: string
              format: uuid
              description: ID of the account.
            user:
              type: string
              format: uuid
              description: ID of the user.
            available_from:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's earliest available gig.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's most recent gig.
            available_count:
              type: integer
              description: Number of gigs currently available for this account.
            removed_count:
              type: integer
              description: Number of gigs removed.
            removed_gigs:
              type: array
              items:
                type: string
                format: uuid
              description: ID's of the removed gigs.
            removed_from:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the earliest removed gig.
            removed_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the most recent removed gig.
      example:
        event: "gigs.removed"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          available_from: "2016-04-16T05:32:41Z"
          available_to: "2023-03-02T00:00:00Z"
          available_count: 2383
          removed_count: 2
          removed_gigs:
            - "0187b43a-35fa-56e2-1a95-f7e4232a4b3a"
            - "0187dbfa-6f5e-a33a-af26-7e12ff408fea"
          removed_from: "2023-03-02T00:00:00Z"
          removed_to: "2023-03-03T00:00:00Z"
    GigsPartiallySyncedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: |
            `gigs.partially_synced`
        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
          description: '`"days_synced": <Integer>` specifies how many days of synced gigs (starting from the date of the most recent gig) are needed to trigger the webhook.'
          properties:
            days_synced:
              type: integer
              description: Specifies how many days of synced gigs
      required:
        - events
        - name
        - url
    GigsPartiallySyncedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: |
            `gigs.partially_synced`
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          description: ''
          properties:
            account:
              type: string
              format: uuid
              description: ID of the account.
            user:
              type: string
              format: uuid
              description: ID of the user.
            available_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's earliest available gig from the synced time period.
            available_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's most recent gig from the synced time period.
            available_count:
              type: integer
              description: Number of gigs currently available for this account at the time this webhook is sent.
            days_synced:
              type: integer
              description: Number of days of synced gig events.
      example:
        event: "gigs.partially_synced"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          available_from: "2023-01-02T00:00:00Z"
          available_to: "2023-03-03T00:00:00Z"
          available_count: 132
          days_synced: 60
    GigsFullySyncedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: |
            `gigs.fully_synced`
        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
    GigsFullySyncedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: |
            `gigs.fully_synced`
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          description: ''
          properties:
            account:
              type: string
              format: uuid
              description: ID of the account.
            user:
              type: string
              format: uuid
              description: ID of the user.
            available_from:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's earliest available gig.
            available_to:
              type: string
              format: date-time
              description: Timestamp (ISO 8601) of the account's most recent gig.
            available_count:
              type: integer
              description: Number of gigs currently available for this account.
      example:
        event: "gigs.fully_synced"
        name: "name-for-the-webhook-subscription"
        data:
          account: "0187c66e-e7e5-811c-b006-2232f00f426a"
          user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69"
          available_from: "2016-04-16T05:32:41Z"
          available_to: "2023-03-02T00:00:00Z"
          available_count: 2379
