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

# Create a webhook



## OpenAPI

````yaml post /webhooks
openapi: 3.0.0
info:
  title: Hub2 Service · Api
  description: |-
    This is the Hub2 api reference |
          Please check https://docs.hub2.io/ for the full documentation |
          Rate limits of endpoints are here : https://docs.hub2.io/en/details/limits.html.
  version: 2.149.1
  contact:
    name: Hub2
    url: https://www.hub2.io/
    email: contact@hub2.io
servers: []
security: []
tags:
  - name: Payments
    description: >-
      Best known as the PAY-IN API, it provides endpoints for merchants to
      perform Hub2 PAY-IN transactions.
  - name: Transfers
    description: >-
      Best known as the PAY-OUT API, it provides endpoints for merchants to
      perform Hub2 PAY-OUT transactions.
  - name: IRT
    description: International Remittance Transfers
  - name: Balance
    description: ''
  - name: Webhooks
    description: ''
  - name: Provisioning
    description: ''
  - name: Payment on Terminal
    description: ''
  - name: Receipt
    description: ''
  - name: Sms
    description: ''
  - name: Data
    description: ''
  - name: Compliance
    description: ''
  - name: Recipient
    description: ''
  - name: Delegation
    description: ''
  - name: Deposits
    description: ''
  - name: Payment Links
    description: ''
  - name: Submerchants
    description: ''
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Create a webhook
      operationId: WebhooksController_create
      parameters:
        - name: ApiKey
          in: header
          description: >-
            Your api key. To create a key, please get into our dashboard. If you
            don't have access to it, please reach the Support team.
          required: true
          schema:
            type: string
        - name: MerchantId
          in: header
          description: >-
            Your merchant ID. This information is available in our dashboard. If
            you don't have access to it, please reach the Support team.
          required: true
          schema:
            type: string
        - name: Environment
          in: header
          description: >-
            Allow you to choose between the sandbox mode to perform some tests
            or the live mode for real world transactions.
          required: true
          schema:
            enum:
              - live
              - sandbox
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookDtoAlias'
        '401':
          description: Wrong credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiUnauthorizedErrorAlias'
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiInternalErrorAlias'
components:
  schemas:
    CreateWebhookDto:
      type: object
      properties:
        url:
          type: string
          description: >-
            Fully qualified url, starting with https://, of the webhook
            endpoint.
          example: https://my.webhook.target
        events:
          type: array
          description: The list of events to enable for this endpoint.
          example:
            - payment.created
            - payment_intent.created
          items:
            type: string
            enum:
              - receipt.created
              - sms.created
              - sms.sent
              - sms.received
              - sms.failed
              - transfer.created
              - transfer.processing
              - transfer.succeeded
              - transfer.failed
              - transfer_irt.created
              - transfer_irt.processing
              - transfer_irt.succeeded
              - transfer_irt.failed
              - deposit.created
              - deposit.pending
              - deposit.success
              - deposit.failed
              - payment_intent.created
              - payment_intent.processing
              - payment_intent.succeeded
              - payment_intent.action_required
              - payment_intent.payment_failed
              - payment.created
              - payment.pending
              - payment.succeeded
              - payment.action_required
              - payment.failed
              - provisioning.created
              - provisioning.succeeded
              - provisioning.failed
              - refund.created
              - refund.pending
              - refund.pending_manual
              - refund.failed
              - refund.successful
              - payment_refund.created
              - payment_refund.pending
              - payment_refund.pending_manual
              - payment_refund.failed
              - payment_refund.successful
              - transaction.payment_collected
              - transaction.deposit
              - provider.wave
              - payment_links.created
              - payment_links.expired
              - payment_links.completed
              - payment_links.closed
              - payment_links.paid
              - submerchant.created
              - submerchant.updated
        description:
          type: string
          description: An optional description of what the webhook is used for.
          example: This is a webhook trigger upon payment & payment_intent creation
        metadata:
          type: object
          description: >-
            Set of key-value pairs that you can attach to an object. This can be
            useful for storing additional information about the object in a
            structured format.
          example: {}
      required:
        - url
        - events
    WebhookDtoAlias:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the Webhook
          example: wh_z1urYtVFgEebtcj8fxp4v
        createdAt:
          type: string
          description: |-
            Datetime in UTC timezone at which this object was created.
                 Follows the [Datetime ISO](https://en.wikipedia.org/wiki/ISO_8601).
          example: '2020-10-15T12:09:49.355Z'
        updatedAt:
          type: string
          description: |-
            Datetime in UTC timezone at which this object was updated.
                 Follows the [Datetime ISO](https://en.wikipedia.org/wiki/ISO_8601).
          example: '2020-10-15T12:09:49.355Z'
        mode:
          type: string
          description: |-
            Mode in which this Webhook exists.
                The sandbox mode can be used during the integration phase and is available as soon as the merchant account is created. No real transactions are made in this mode.
                The live mode has to be used to make real transactions.
          example: live
          enum:
            - live
            - sandbox
        description:
          type: string
          description: An optional description of what the webhook is used for.
          example: This is a webhook trigger upon payment & payment_intent creation
        events:
          description: The list of events to enable for this endpoint.
          example:
            - payment.created
            - payment_intent.created
          type: array
          items:
            type: string
        metadata:
          type: object
          description: >-
            Set of key-value pairs that you can attach to an object. This can be
            useful for storing additional information about the object in a
            structured format.
          example: {}
        secret:
          type: string
          description: >-
            The endpoint’s secret, used to generate webhook signatures. Only
            returned at creation.
          example: 5257a869e7ecebeda32affa62cd...
        status:
          type: string
          description: The webhook status
          example: enabled
          enum:
            - enabled
            - disabled
        url:
          type: string
          description: Fully qualified url of the webhook endpoint.
          example: https://my.webhook.target
      required:
        - id
        - createdAt
        - updatedAt
        - mode
        - events
        - metadata
        - status
        - url
    ApiUnauthorizedErrorAlias:
      type: object
      properties:
        status:
          type: number
          description: HTTP error code.
          example: 401
        error:
          description: HTTP error description.
          allOf:
            - $ref: '#/components/schemas/InternalApiUnauthorizedError'
      required:
        - status
        - error
    ApiInternalErrorAlias:
      type: object
      properties:
        type:
          type: string
          description: The type of this error.
          example: internal_error
        code:
          type: string
          description: The error code for this error.
          example:
            - internal_error
            - wrong_credentials
            - not_granted
            - live_mode_not_granted
            - invalid_sandbox_msisdn
            - invalid_url
            - orange_invalid_url
            - wrong_provider
            - override_business_name
            - do_not_override_business_name
        message:
          type: string
          description: The error message describing what happens to throw this error.
          example: An error occurred on our system. Please try again later.
      required:
        - type
        - code
        - message
    InternalApiUnauthorizedError:
      type: object
      properties:
        type:
          type: string
          description: The type of this error.
          example: authorization_error
        code:
          type: string
          description: The internal error code describing what happened.
          enum:
            - bad_payment_intent_token
            - wrong_credentials
          example: wrong_credentials
        message:
          type: string
          description: Detailed error message which describe what happened.
          example: L'ID marchand et/ou la clé d'API sont incorrects.
      required:
        - type
        - code
        - message

````