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

# Subscribe to a rest hook

> Registers a URL that receives a POST request each time the given rest hook event happens in the community. The response contains the id of the subscription, which can be used to unsubscribe



## OpenAPI

````yaml https://api.zapnito.com/api/docs/v1/swagger.json post /api/v1/rest_hooks/{key}/subscriptions
openapi: 3.0.1
info:
  title: API V1
  version: v1
  description: Zapnito API Documentation
servers:
  - url: https://{host}
    description: Your community domain
    variables:
      host:
        default: your-community.com
        description: Your community domain, for example your-community.com
security: []
tags:
  - name: Health Check
    description: Check that the API is reachable and that your API key is valid
  - name: Identity
    description: Find out which community your API key belongs to
  - name: Users
    description: >-
      Look up the people in your community, update their profile and choose
      which notifications they receive
  - name: Organisations
    description: >-
      Create and update the organisations in your community and manage who
      belongs to them
  - name: Groups
    description: Create groups and manage which users belong to them
  - name: Invitations
    description: Invite people to join your community
  - name: Posts
    description: Create, read and update posts on behalf of your community members
  - name: Contents
    description: >-
      Read the published content of your community and publish, schedule or
      unpublish it
  - name: Channels
    description: List the channels in your community and the content published in each
  - name: Rooms
    description: Create and read the rooms where your community members meet
  - name: Tags
    description: Create tags and apply them to content
  - name: Badges
    description: Create badges and award them to content or to users
  - name: Custom Fields
    description: Read the custom profile fields your community asks its members to fill in
  - name: Third-Party Resources
    description: >-
      Link to resources hosted outside your community so they appear alongside
      your content
  - name: Rest Hooks
    description: >-
      Subscribe a URL to events in your community, so you are told when they
      happen
paths:
  /api/v1/rest_hooks/{key}/subscriptions:
    parameters:
      - name: key
        in: path
        required: true
        description: >-
          The rest hook key (for example user_registered, user_updated,
          user_deleted)
        schema:
          type: string
    post:
      tags:
        - Rest Hooks
      summary: Subscribe to a rest hook
      description: >-
        Registers a URL that receives a POST request each time the given rest
        hook event happens in the community. The response contains the id of the
        subscription, which can be used to unsubscribe
      operationId: subscribeToRestHook
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RestHookSubscriptionCreateRequest'
            examples:
              new_subscription:
                summary: A subscription to a URL
                value:
                  rest_hook_subscription:
                    url: https://example.com/hooks/user-registered
        required: true
        description: Subscription payload wrapped in a rest_hook_subscription object
      responses:
        '200':
          description: >-
            The request failed validation, so no subscription was created. The
            errors are in the response body
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: object
                    properties:
                      url:
                        type: array
                        items:
                          type: string
                        example:
                          - can't be blank
                required:
                  - errors
        '201':
          description: The subscription was created
          content:
            application/json:
              examples:
                example:
                  value:
                    id: 42
              schema:
                $ref: '#/components/schemas/RestHookSubscription'
        '400':
          description: >-
            The rest_hook_subscription object is missing. The response has no
            body
        '401':
          description: >-
            The API key is missing or invalid. The response body is the text
            `HTTP Token: Access denied.`
      security:
        - tokenAuth: []
components:
  schemas:
    RestHookSubscriptionCreateRequest:
      type: object
      properties:
        rest_hook_subscription:
          type: object
          properties:
            url:
              type: string
              example: https://example.com/hooks/user-registered
            authorization_token:
              type: string
              example: abcdefghijklmnopqrstuvwxyz
              description: >-
                Optional token sent with each delivery so your endpoint can
                verify the request
          required:
            - url
      required:
        - rest_hook_subscription
    RestHookSubscription:
      type: object
      properties:
        id:
          type: integer
          example: 42
      required:
        - id
  securitySchemes:
    tokenAuth:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        API authentication using your community API secret. The value below is
        sent as the Authorization header verbatim, so paste the whole header
        value including the prefix: Token token=<api-key>
      x-default: Token token=<api-key>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.