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

# Configure Webhook

> Registers or updates the webhook URL that receives event notifications for your organization.

<Prompt description="Configure Webhook" actions={["cursor"]}>
  Integrate the DollarPe Configure Webhook endpoint into my application.

  Endpoint: POST /organizations/api-webhooks
  Base URL: [https://api.dollarpe.in](https://api.dollarpe.in) (production) | [https://sandbox.dollarpe.in](https://sandbox.dollarpe.in) (sandbox)

  Auth headers required on every request:

  * X-API-KEY: your API key
  * X-TIMESTAMP: current Unix time in seconds
  * X-SIGNATURE: Base64(HMAC-SHA256(X-API-KEY + X-TIMESTAMP + sortedJSONBody, apiSecret))

  Task: Write a typed function that:

  1. Accepts the webhook URL and the list of event types to subscribe to
  2. Builds the signed auth headers
  3. Calls POST /organizations/api-webhooks
  4. Returns the webhook configuration
  5. Handles 400 (invalid URL, unsupported event types) and 500 errors

  Also write a webhook handler that:

  1. Verifies the incoming signature using HMAC-SHA256
  2. Parses the event type and payload
  3. Routes events to the appropriate handlers (payin status, payout status, KYC status)

  Language: TypeScript
</Prompt>

| API Status Code | Response                | Reason                  |
| --------------- | ----------------------- | ----------------------- |
| 400             | Webhook URL is required | Webhook URL is required |
| 500             | Internal Server Error   | Internal Server Error   |


## OpenAPI

````yaml POST /organizations/api-webhooks
openapi: 3.1.0
info:
  title: DollarPe API
  description: API for DollarPe - Customer, Payout, and Webhook services
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://sandbox.dollarpe.xyz/pos/api/v1
    description: Payout API Base URL
    variables:
      base_url:
        default: https://sandbox.dollarpe.xyz
  - url: https://sandbox.dollarpe.xyz/cms/api/v1
    description: Customer API Base URL
    variables:
      base_url:
        default: https://sandbox.dollarpe.xyz
security:
  - ApiKeyAuth: []
    TimestampAuth: []
    SignatureAuth: []
tags:
  - name: Customer
    description: Customer related operations
    x-displayName: Customer
    x-traitTag: true
  - name: Payout
    description: Payout related operations
  - name: Webhooks
    description: Webhook related operations
  - name: Widget
    description: Hosted buy/sell widget session initialization
paths:
  /organizations/api-webhooks:
    post:
      tags:
        - Webhook
      description: Configure the webhook URL for receiving transaction status updates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - webhook_url
              properties:
                webhook_url:
                  type: string
                  format: uri
                  description: The HTTPS URL where webhook events will be sent
                  example: www.testwh1fromapi.com/w1
      responses:
        '200':
          description: Webhook URL configured successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Success
                  data:
                    type: string
                    example: www.testwh1fromapi.com/w1
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Internal Server Error
                  err_code:
                    type: string
                    example: SYS_INTERNAL_ERROR
                  errors:
                    type: string
                    example: Unexpected error occurred. Please try again later.
                  data:
                    type: 'null'
      servers:
        - url: https://sandbox.dollarpe.xyz/org/api/v1
          description: Webhook API Base URL
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: API Key for authentication
    TimestampAuth:
      type: apiKey
      in: header
      name: X-TIMESTAMP
      description: Current timestamp in seconds since epoch
    SignatureAuth:
      type: apiKey
      in: header
      name: X-SIGNATURE
      description: HMAC SHA256 signature of the request encoded in Base64

````