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

# Create Webhook

> Register a new webhook endpoint

Creates a new webhook endpoint to receive real-time notifications for swap and on-ramp events. Requires a valid API key.

<ParamField body="url" type="string" required>
  The HTTPS URL to receive webhook payloads.
</ParamField>

<ParamField body="events" type="string[]" required>
  List of event types to subscribe to. See [Webhooks Guide](/guides/webhooks) for available events.
</ParamField>

<ParamField body="secret" type="string">
  A signing secret for HMAC-SHA256 signature verification. If not provided, one will be generated.
</ParamField>

<ResponseExample>
  ```json 200 theme={"system"}
  {
    "data": {
      "id": "whk_abc123def456",
      "url": "https://yourapp.com/webhooks/hypermid",
      "events": ["swap.completed", "swap.failed", "onramp.completed"],
      "secret": "whsec_generated_or_provided_secret",
      "active": true,
      "createdAt": "2024-03-25T10:30:00Z"
    },
    "error": null,
    "meta": {
      "requestId": "z6c7d8e9-f0a1-2345-9012-456789012345",
      "timestamp": 1711234584,
      "rateLimit": {
        "limit": 2000,
        "remaining": 1974,
        "reset": 1711234627
      }
    }
  }
  ```
</ResponseExample>

<CodeGroup>
  ```typescript TypeScript theme={"system"}
  const webhook = await client.createWebhook({
    url: "https://yourapp.com/webhooks/hypermid",
    events: ["swap.completed", "swap.failed", "onramp.completed", "onramp.failed"],
    secret: "whsec_my_signing_secret",
  });

  console.log("Webhook ID:", webhook.data.id);
  console.log("Secret:", webhook.data.secret);
  ```

  ```bash cURL theme={"system"}
  curl -X POST "https://api.hypermid.io/v1/partner/webhooks" \
    -H "Content-Type: application/json" \
    -H "X-API-Key: your-api-key" \
    -d '{
      "url": "https://yourapp.com/webhooks/hypermid",
      "events": ["swap.completed", "swap.failed", "onramp.completed"],
      "secret": "whsec_my_signing_secret"
    }'
  ```

  ```go Go theme={"system"}
  body := `{
    "url": "https://yourapp.com/webhooks/hypermid",
    "events": ["swap.completed", "swap.failed", "onramp.completed"],
    "secret": "whsec_my_signing_secret"
  }`

  req, _ := http.NewRequest("POST",
      "https://api.hypermid.io/v1/partner/webhooks",
      strings.NewReader(body))
  req.Header.Set("Content-Type", "application/json")
  req.Header.Set("X-API-Key", "your-api-key")
  resp, _ := http.DefaultClient.Do(req)
  ```
</CodeGroup>

<Warning>
  Store the webhook `secret` securely. You will need it to verify webhook signatures. If you lose it, delete the webhook and create a new one.
</Warning>


## OpenAPI

````yaml POST /v1/partner/webhooks
openapi: 3.0.3
info:
  title: Hypermid Partner API
  version: 1.0.0
  description: >-
    Cross-chain swap aggregator API. Supports 30+ EVM chains, Solana, Bitcoin,
    Sui, and Near Intents chains (NEAR, TON, Tron, XRP, etc.).


    ## Authentication

    Pass your API key via the `X-API-Key` header. Public endpoints work without
    a key (anonymous tier). Partner endpoints (`/v1/partner/*`) require a valid
    key.


    ## Rate Limits

    - **Anonymous**: 30 requests/minute (per IP)

    - **Partner (authenticated)**: 100 requests/minute (per API key)


    These limits are designed for human-driven widget usage and mirror our
    upstream aggregator (LiFi) limits to prevent any single user from exhausting
    shared quota.


    Rate limit info is returned in `meta.rateLimit` on every response.


    ## Response Envelope

    All responses follow the shape:

    ```json

    { "data": <T | null>, "error": <{ code, message, details? } | null>, "meta":
    { "requestId", "timestamp", "rateLimit?" } }

    ```
  contact:
    name: Hypermid
    url: https://hypermid.io
servers:
  - url: https://api.hypermid.io
    description: Production
security:
  - ApiKeyAuth: []
  - {}
tags:
  - name: Swap
    description: Cross-chain swap quoting, routing, status, and reference data
  - name: Execute
    description: Transaction execution and deposit management for Near Intents swaps
  - name: On-Ramp
    description: Fiat-to-crypto on-ramp via RampNow
  - name: Partner
    description: Partner account, analytics, and webhook management (requires X-API-Key)
  - name: Tracking
    description: Swap event tracking for partner attribution
  - name: System
    description: Health check and API metadata
paths:
  /v1/partner/webhooks:
    post:
      tags:
        - Partner
      summary: Register a webhook
      description: >-
        Register a new webhook endpoint. The signing secret is returned only in
        the creation response. Supported events: swap.completed,
        onramp.completed.
      operationId: createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreateRequest'
      responses:
        '201':
          description: Webhook created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/WebhookCreateResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    WebhookCreateRequest:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: Must use HTTPS
        events:
          type: array
          items:
            type: string
            enum:
              - swap.completed
              - onramp.completed
          default:
            - swap.completed
      required:
        - url
    ApiResponse:
      type: object
      properties:
        data:
          description: Response payload (null on error)
        error:
          nullable: true
          type: object
          properties:
            code:
              type: string
              example: INVALID_PARAMS
            message:
              type: string
              example: 'Missing required parameters: fromChain'
            details:
              type: object
              additionalProperties: true
          required:
            - code
            - message
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - data
        - error
        - meta
    WebhookCreateResponse:
      type: object
      properties:
        id:
          type: string
        url:
          type: string
        events:
          type: array
          items:
            type: string
        secret:
          type: string
          description: HMAC signing secret. Only returned on creation.
        status:
          type: string
    Meta:
      type: object
      properties:
        requestId:
          type: string
          format: uuid
        timestamp:
          type: integer
          description: Unix epoch seconds
        rateLimit:
          type: object
          properties:
            limit:
              type: integer
            remaining:
              type: integer
            reset:
              type: integer
              description: Unix epoch seconds when the window resets
      required:
        - requestId
        - timestamp
  responses:
    BadRequest:
      description: Invalid or missing parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiResponse'
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Partner API key. Optional for public endpoints, required for
        /v1/partner/*.

````