openapi: 3.0.0
info:
  title: Shifts Webhooks
  version: '1.0'
  description: |
    Sent when shifts are added, updated, or removed.

    If you need to access to shift data as soon as it is available:

    *   The `shifts.partially_synced` webhook is sent when shifts going back a specified number of days prior (starting from the date [when the account was added](/api-reference/accounts-webhooks/added)) have been retrieved during initial data retrieval for a newly connected account.
    *   The `shifts.fully_synced` webhook is sent when all shifts have been retrieved during initial data retrieval for a newly connected account.

    Because some accounts can contain hundreds of shifts, we recommend subscribing to the `shifts.partially_synced` webhook when especially time-sensitive. The `shifts.fully_synced` webhook will only be sent when all shift 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 `shifts.removed` webhook is sent when a shift object has been deleted after a previous shift was not found when an account's data was refreshed.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ShiftsRemovedWebhookRequest'
            examples:
              shifts_removed_subscription:
                summary: shifts.removed subscription
                value:
                  events:
                  - shifts.removed
                  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/ShiftsRemovedWebhookResponse'
              examples:
                shifts_removed:
                  summary: Shifts removed
                  value:
                    event: "shifts.removed"
                    name: "name-for-the-webhook-subscription"
                    data:
                      account: "0187c66e-e7e5-811c-b006-2232f00f426a" # ID of the account.
                      user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69" # ID of the user.
                      available_from: "2016-04-16T05:32:41Z" # Timestamp (ISO 8601) of the account's earliest available shift.
                      available_to: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the account's most recent shift.
                      available_count: 410 # Number of shifts currently available for this account.
                      removed_count: 2 # Number of shifts removed.
                      removed_shifts:
                        - "0187b43a-35fa-56e2-1a95-f7e4232a4b3a" # ID's of the removed shifts.
                        - "0187dbfa-6f5e-a33a-af26-7e12ff408fea"
                      removed_from: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the earliest removed shift.
                      removed_to: "2023-03-03T00:00:00Z" # Timestamp (ISO 8601) of the most recent removed shift.

  
  # /v2/webhooks:
  #   post:
  #     summary: Updated
  #     description: |
  #       The `shifts.updated` webhook is sent when there is any change to a property value of the [shift object](/api-reference/shifts#object).

  #       For example, after a shift is completed the shift object's `status` value changes from `in_progress` to `completed`.
  #     requestBody:
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/ShiftsUpdatedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Success
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/ShiftsUpdatedWebhookResponse'
  #             example:
  #               event: "shifts.updated"
  #               name: "name-for-the-webhook-subscription"
  #               data:
  #                 account: "0187c66e-e7e5-811c-b006-2232f00f426a" # ID of the account.
  #                 user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69" # ID of the user.
  #                 available_from: "2016-04-16T05:32:41Z" # Timestamp (ISO 8601) of the account's earliest available shift.
  #                 available_to: "2023-03-03T00:00:00Z" # Timestamp (ISO 8601) of the account's most recent shift.
  #                 available_count: 412 # Number of shifts currently available for this account.
  #                 updated_count: 2 # Number of shifts updated.
  #                 updated_shifts:
  #                   - "0187b43a-35fa-56e2-1a95-f7e4232a4b3a" # ID's of the updated shifts.
  #                   - "0187dbfa-6f5e-a33a-af26-7e12ff408fea"
  #                 updated_from: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the earliest updated shift.
  #                 updated_to: "2023-03-03T00:00:00Z" # Timestamp (ISO 8601) of the most recent updated shift.
  # /v2/webhooks:
  #   post:
  #     summary: Removed
  #     description: |
  #       The `shifts.removed` webhook is sent when a shift object has been deleted after a previous shift was not found when an account's data was refreshed.
  #     requestBody:
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/ShiftsRemovedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Success
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/ShiftsRemovedWebhookResponse'
  #             example:
  #               event: "shifts.removed"
  #               name: "name-for-the-webhook-subscription"
  #               data:
  #                 account: "0187c66e-e7e5-811c-b006-2232f00f426a" # ID of the account.
  #                 user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69" # ID of the user.
  #                 available_from: "2016-04-16T05:32:41Z" # Timestamp (ISO 8601) of the account's earliest available shift.
  #                 available_to: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the account's most recent shift.
  #                 available_count: 410 # Number of shifts currently available for this account.
  #                 removed_count: 2 # Number of shifts removed.
  #                 removed_shifts:
  #                   - "0187b43a-35fa-56e2-1a95-f7e4232a4b3a" # ID's of the removed shifts.
  #                   - "0187dbfa-6f5e-a33a-af26-7e12ff408fea"
  #                 removed_from: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the earliest removed shift.
  #                 removed_to: "2023-03-03T00:00:00Z" # Timestamp (ISO 8601) of the most recent removed shift.
  # /v2/webhooks:
  #   post:
  #     summary: Partially synced
  #     description: |
  #       The `shifts.partially_synced` webhook is sent when shifts going back a specified number of days prior (starting from the date [when the account was added](/api-reference/accounts-webhooks/added)) have been retrieved. By default, this period is set to 30 days.

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

  #       Of note:

  #       *   This webhook is sent only during initial data retrieval (not [ongoing refresh](/overview/ongoing-refresh)).
  #       *   If the number of shifts for an account is small and captured completely with only one data pull, this webhook will not be sent. Instead the `shifts.fully_synced` webhook will be sent.
  #     requestBody:
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/ShiftsPartiallySyncedRequest'
  #     responses:
  #       '200':
  #         description: Success
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/ShiftsPartiallySyncedResponse'
  #             example:
  #               event: "shifts.partially_synced"
  #               name: "name-for-the-webhook-subscription"
  #               data:
  #                 account: "0187c66e-e7e5-811c-b006-2232f00f426a" # ID of the account.
  #                 user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69" # ID of the user.
  #                 available_from: "2023-01-02T0:000:00Z" # Timestamp (ISO 8601) of the account's earliest available shift from the synced time period.
  #                 available_to: "2023-03-03T0:000:00Z" # Timestamp (ISO 8601) of the account's most recent shift from the synced time period.
  #                 available_count: 97 # Number of shifts currently available for this account at the time this webhook is sent.
  #                 days_synced: 60 # Number of days of synced shift events.
  # /v2/webhooks:
  #   post:
  #     summary: Fully synced
  #     description: |
  #       The `shifts.fully_synced` webhook is sent when all shifts have been retrieved from a newly connected payroll account.
  #     requestBody:
  #       content:
  #         application/json:
  #           schema:
  #             $ref: '#/components/schemas/ShiftsFullySyncedWebhookRequest'
  #     responses:
  #       '200':
  #         description: Success
  #         content:
  #           application/json:
  #             schema:
  #               $ref: '#/components/schemas/ShiftsFullySyncedWebhookResponse'
  #             example:
  #               event: "shifts.fully_synced"
  #               name: "name-for-the-webhook-subscription"
  #               data:
  #                 account: "0187c66e-e7e5-811c-b006-2232f00f426a" # ID of the account.
  #                 user: "018051aa-f7a9-a0db-2f38-6cfa325e9d69" # ID of the user.
  #                 available_from: "2016-04-16T05:32:41Z" # Timestamp (ISO 8601) of the account's earliest available shift.
  #                 available_to: "2023-03-02T00:00:00Z" # Timestamp (ISO 8601) of the account's most recent shift.
  #                 available_count: 412 # Number of shifts currently available for this account.

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Username = api_key_id, Password = api_key_secret
  schemas:
    ShiftsAddedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: "`shifts.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](/api-guide/webhooks#verifying-webhooks).
      required:
        - events
        - name
        - url
    ShiftsAddedResponse:
      type: object
      properties:
        event:
          type: string
          description: "`shifts.added`"
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          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 earliest available shift.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the most recent shift.
            available_count:
              type: integer
              description: Number of shifts currently available for this account.
            added_count:
              type: integer
              description: Number of shifts retrieved during a data refresh.
            added_from:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the earliest shift retrieved during a [data refresh](/overview/ongoing-refresh).
            added_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the most recent shift retrieved during a data refresh.
    ShiftsUpdatedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: "`shifts.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](/api-guide/webhooks#verifying-webhooks).
      required:
        - events
        - name
        - url
    ShiftsUpdatedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: "`shifts.updated`"
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          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 shift.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's most recent shift.
            available_count:
              type: integer
              description: Number of shifts currently available for this account.
            updated_count:
              type: integer
              description: Number of shifts updated.
            updated_shifts:
              type: array
              items:
                type: string
                format: uuid
              description: ID's of the updated shifts.
            updated_from:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the earliest updated shift.
            updated_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the most recent updated shift.
    ShiftsRemovedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: "`shifts.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:
        - shifts.removed
        name: name-for-the-webhook-subscription
        url: https://your-webhook-backend.com
        secret: optional-secret
    ShiftsRemovedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: "`shifts.removed`"
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          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 shift.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's most recent shift.
            available_count:
              type: integer
              description: Number of shifts currently available for this account.
            removed_count:
              type: integer
              description: Number of shifts removed.
            removed_shifts:
              type: array
              items:
                type: string
                format: uuid
              description: ID's of the removed shifts.
            removed_from:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the earliest removed shift.
            removed_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the most recent removed shift.
    ShiftsPartiallySyncedRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: "`shifts.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](/api-guide/webhooks#verifying-webhooks).
        config:
          type: object
          description: "`days_synced`: <Integer> specifies how many days of synced shifts (starting from the date of the most recent shift) are needed to trigger the webhook."
      required:
        - events
        - name
        - url
    ShiftsPartiallySyncedResponse:
      type: object
      properties:
        event:
          type: string
          description: "`shifts.partially_synced`"
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          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 shift from the synced time period.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's most recent shift from the synced time period.
            available_count:
              type: integer
              description: Number of shifts currently available for this account at the time this webhook is sent.
            days_synced:
              type: integer
              description: Number of days of synced shift events.
    ShiftsFullySyncedWebhookRequest:
      type: object
      properties:
        events:
          type: array
          items:
            type: string
          description: "`shifts.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](/api-guide/webhooks#verifying-webhooks).
      required:
        - events
        - name
        - url
    ShiftsFullySyncedWebhookResponse:
      type: object
      properties:
        event:
          type: string
          description: "`shifts.fully_synced`"
        name:
          type: string
          description: Name used for the webhook subscription.
        data:
          type: object
          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 shift.
            available_to:
              type: string
              format: date-time
              description: Timestamp ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)) of the account's most recent shift.
            available_count:
              type: integer
              description: Number of shifts currently available for this account.
