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

# Create a webhook

> Make a signed endpoint that gets the PostSyncer events you choose.

> [!NOTE]
>
> Needs `webhooks:create`, and a role in the workspace that can manage notifications: owners and managers can. See [Permissions](/docs/essentials/authentication.md#permissions).

Makes an endpoint: a public `https://` address on your side that gets a signed JSON request for each event it listens for. [Webhooks](/docs/api-reference/webhooks/overview.md) lists the events and what each one holds.

> [!WARNING]
>
> The answer has the signing secret in full, in `secret`, this once. Store it now: the API never gives it again. In the app, under **Settings → Notifications → Webhooks**, you can see it again or make a new one. [Verify webhooks](/docs/guides/verify-webhooks.md) shows how to check each request with it.

* `events` needs at least one event.
* `account_ids` keeps the events about some social accounts. Left out, empty or `null`: every account.
* `workspace_ids` also sends the events of other workspaces, where your role must let you manage notifications too. An id may be a number or a string of digits (`15` or `"15"`), and comes back as a number. `["*"]` sends the events of every workspace the owner has, and only the workspace owner can set it. Left out, empty or `null`: this workspace alone.
* `active: false` makes the endpoint switched off: nothing is sent until you turn it on with [Update a webhook](/docs/api-reference/webhooks/update.md). Left out, it is on.

The address must be public: private, loopback and reserved addresses are refused, and PostSyncer checks again each time it sends. Your server should answer with a `2xx` within 10 seconds. Redirects aren't followed: a `3xx` answer fails, so use the address it redirects to. A workspace has at most 20 endpoints; one more is refused with `422` on `name`. Webhooks work on every plan.

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `webhooks:create`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't manage notifications, `workspace_ids` names a workspace where it can't, or `["*"]` comes from someone who isn't the owner. | No. |
| 422 | | A field is missing or wrong: an address that isn't public `https://`, no events, an event that doesn't exist or that a webhook can't get, an account the key can't reach, `*` with workspace ids (`Use * alone, or a list of workspaces.`), or a workspace id that is neither a number nor `*` (`Use workspace ids, or * for every workspace.`). Also a workspace the key can't reach, or one with 20 endpoints. | No: fix the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [Send a test event](/docs/api-reference/webhooks/test.md): check your server gets and verifies it.
* [Verify webhooks](/docs/guides/verify-webhooks.md): check the signature.


## OpenAPI

````yaml POST /webhooks
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 12 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Create a webhook
      description: >-
        Needs `webhooks:create`. Your role in the workspace must also let you
        manage notifications: owners and managers can. Makes a signed endpoint
        that gets the events you choose. The answer has the signing secret in
        full, this once: the API never gives it again (in the app you can see it
        again or make a new one). A workspace has at most 20 endpoints. Webhooks
        work on every plan, Free included.
      operationId: createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspace_id
                - name
                - url
                - events
              properties:
                workspace_id:
                  type: integer
                  description: >-
                    The workspace it belongs to. It must be one the key can
                    reach.
                name:
                  type: string
                  maxLength: 100
                  description: A name for the endpoint.
                url:
                  type: string
                  maxLength: 2048
                  description: >-
                    A public `https://` address that gets the events. Private,
                    internal and reserved addresses are refused.
                events:
                  type: array
                  minItems: 1
                  items:
                    type: string
                    enum:
                      - post.published
                      - post.partially_published
                      - post.failed
                      - post.account_published
                      - post.account_failed
                      - post.scheduled
                      - post.deleted
                      - post.needs_media
                      - posts.bulk_removed
                      - approval.requested
                      - approval.approved
                      - approval.rejected
                      - account.needs_reconnect
                      - account.expires_soon
                      - account.paused
                      - account.connected
                      - account.disconnected
                      - account.posts_to_put_back
                      - comment.mentioned
                      - comment.received
                      - share.comment_received
                      - review.received
                      - media.generated
                      - media.generation_failed
                      - brand.learned
                      - team.member_joined
                      - webhook.test
                  description: The events it gets, at least one.
                account_ids:
                  type: array
                  nullable: true
                  items:
                    type: integer
                  description: >-
                    Only events about these social accounts, each one the key
                    can reach. Empty or null: every account.
                workspace_ids:
                  type: array
                  nullable: true
                  items:
                    oneOf:
                      - type: integer
                      - type: string
                        pattern: ^[0-9]+$
                        description: A workspace id as a string of digits, like `"15"`.
                      - type: string
                        enum:
                          - '*'
                  description: >-
                    Also send the events of these workspaces, where your role
                    must let you manage notifications, or `["*"]` for every
                    workspace the owner has (the workspace owner only). An id
                    may be a number or a string of digits (`15` or `"15"`); it
                    comes back as a number. Empty or null: this workspace alone.
                active:
                  type: boolean
                  default: true
                  description: >-
                    `false` makes it switched off: nothing is sent until you
                    turn it on with Update a webhook.
            examples:
              default:
                summary: Failed posts
                value:
                  workspace_id: 12
                  name: Failed posts to our CRM
                  url: https://hooks.haldencoffee.com/postsyncer
                  events:
                    - post.failed
                    - post.account_failed
              'off':
                summary: Made switched off
                value:
                  workspace_id: 12
                  name: Failed posts to our CRM
                  url: https://hooks.haldencoffee.com/postsyncer
                  events:
                    - post.failed
                    - post.account_failed
                  active: false
              some_accounts:
                summary: One account, two workspaces
                value:
                  workspace_id: 12
                  name: Instagram comments
                  url: https://hooks.haldencoffee.com/comments
                  events:
                    - comment.received
                  account_ids:
                    - 136
                  workspace_ids:
                    - 12
                    - 15
      responses:
        '201':
          description: The webhook, with its secret.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Webhook'
              examples:
                default:
                  summary: Failed posts
                  value:
                    id: 42
                    workspace_id: 12
                    kind: webhook
                    name: Failed posts to our CRM
                    url: https://hooks.haldencoffee.com/postsyncer
                    url_masked: false
                    secret_last4: 0aCe
                    events:
                      - post.failed
                      - post.account_failed
                    account_ids: null
                    workspace_ids: null
                    active: true
                    failing_since: null
                    disabled_reason: null
                    created_at: '2030-03-08T09:00:00+00:00'
                    updated_at: '2030-03-08T09:00:00+00:00'
                    stats_7d:
                      sent: 0
                      failed: 0
                      daily:
                        - date: '2030-03-09'
                          sent: 0
                          failed: 0
                        - date: '2030-03-10'
                          sent: 0
                          failed: 0
                        - date: '2030-03-11'
                          sent: 0
                          failed: 0
                        - date: '2030-03-12'
                          sent: 0
                          failed: 0
                        - date: '2030-03-13'
                          sent: 0
                          failed: 0
                        - date: '2030-03-14'
                          sent: 0
                          failed: 0
                        - date: '2030-03-15'
                          sent: 0
                          failed: 0
                    last_delivery_at: null
                    secret: whsec_k7Qd2mR9vX4bN1pL8sT3wY6zH5jF0aCe
                'off':
                  summary: Made switched off
                  value:
                    id: 42
                    workspace_id: 12
                    kind: webhook
                    name: Failed posts to our CRM
                    url: https://hooks.haldencoffee.com/postsyncer
                    url_masked: false
                    secret_last4: 0aCe
                    events:
                      - post.failed
                      - post.account_failed
                    account_ids: null
                    workspace_ids: null
                    active: false
                    failing_since: null
                    disabled_reason: null
                    created_at: '2030-03-08T09:00:00+00:00'
                    updated_at: '2030-03-08T09:00:00+00:00'
                    stats_7d:
                      sent: 0
                      failed: 0
                      daily:
                        - date: '2030-03-09'
                          sent: 0
                          failed: 0
                        - date: '2030-03-10'
                          sent: 0
                          failed: 0
                        - date: '2030-03-11'
                          sent: 0
                          failed: 0
                        - date: '2030-03-12'
                          sent: 0
                          failed: 0
                        - date: '2030-03-13'
                          sent: 0
                          failed: 0
                        - date: '2030-03-14'
                          sent: 0
                          failed: 0
                        - date: '2030-03-15'
                          sent: 0
                          failed: 0
                    last_delivery_at: null
                    secret: whsec_k7Qd2mR9vX4bN1pL8sT3wY6zH5jF0aCe
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `webhooks:create`, its user is inactive, or your role
            can't manage notifications in the workspace, or `workspace_ids`
            names a workspace you can't send events from.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks webhooks:create
                  value:
                    message: >-
                      This API key does not have the "webhooks:create"
                      permission. Edit the key in PostSyncer under Settings →
                      API to grant it.
                role:
                  summary: The role can't manage notifications
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to edit notifications. Ask the workspace owner or a
                      manager to do it, or to change your role.
                all_workspaces:
                  summary: '`["*"]` from someone who isn''t the owner'
                  value:
                    message: >-
                      Only the owner of this workspace can send events from
                      every workspace.
                other_workspace:
                  summary: A workspace where you can't manage notifications
                  value:
                    message: >-
                      You can only send events from workspaces where you can
                      manage notifications.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '422':
          description: >-
            A field is missing or wrong, the workspace isn't one the key can
            reach, or it already has 20 endpoints. A full workspace is named on
            `name`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: Invalid workspace ID.
                    errors:
                      workspace_id:
                        - Invalid workspace ID.
                events:
                  summary: No events
                  value:
                    message: The events field is required.
                    errors:
                      events:
                        - The events field is required.
                url_https:
                  summary: Not https
                  value:
                    message: The address must start with https://.
                    errors:
                      url:
                        - The address must start with https://.
                url_private:
                  summary: A private address
                  value:
                    message: This address is not allowed. Use a public https address.
                    errors:
                      url:
                        - >-
                          This address is not allowed. Use a public https
                          address.
                event:
                  summary: An event that doesn't exist
                  value:
                    message: One of these events does not exist.
                    errors:
                      events.0:
                        - One of these events does not exist.
                event_not_webhook:
                  summary: An event a webhook can't get
                  value:
                    message: 'This destination cannot get these events: credits.low.'
                    errors:
                      events:
                        - 'This destination cannot get these events: credits.low.'
                account_ids:
                  summary: An account the key can't reach
                  value:
                    message: One of these accounts was not found.
                    errors:
                      account_ids:
                        - One of these accounts was not found.
                workspace_ids:
                  summary: '`*` with workspace ids'
                  value:
                    message: Use * alone, or a list of workspaces.
                    errors:
                      workspace_ids:
                        - Use * alone, or a list of workspaces.
                workspace_ids_type:
                  summary: Not an id or `*`
                  value:
                    message: Use workspace ids, or * for every workspace.
                    errors:
                      workspace_ids:
                        - Use workspace ids, or * for every workspace.
                active:
                  summary: '`active` isn''t a boolean'
                  value:
                    message: The active field must be true or false.
                    errors:
                      active:
                        - The active field must be true or false.
                full:
                  summary: The workspace has 20 endpoints
                  value:
                    message: >-
                      A workspace can have 20 webhook endpoints. Delete one to
                      add another.
                    errors:
                      name:
                        - >-
                          A workspace can have 20 webhook endpoints. Delete one
                          to add another.
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    Webhook:
      type: object
      description: A signed webhook endpoint.
      required:
        - id
        - workspace_id
        - kind
        - name
        - url
        - url_masked
        - secret_last4
        - events
        - account_ids
        - workspace_ids
        - active
        - failing_since
        - disabled_reason
        - created_at
        - updated_at
        - stats_7d
        - last_delivery_at
      properties:
        id:
          type: integer
        workspace_id:
          type: integer
          description: The workspace it belongs to.
        kind:
          type: string
          enum:
            - webhook
        name:
          type: string
          maxLength: 100
        url:
          type: string
          description: >-
            Where the events go. In full when your role lets you edit the
            endpoint; otherwise the scheme and host alone, like
            `https://hooks.haldencoffee.com/…`.
        url_masked:
          type: boolean
          description: True when `url` is cut to the scheme and host.
        secret:
          type: string
          description: >-
            Only in the answer to Create a webhook: the signing secret in full,
            `whsec_` and 32 characters.
        secret_last4:
          type: string
          description: The secret's last four characters, to tell secrets apart.
        events:
          type: array
          items:
            type: string
            enum:
              - post.published
              - post.partially_published
              - post.failed
              - post.account_published
              - post.account_failed
              - post.scheduled
              - post.deleted
              - post.needs_media
              - posts.bulk_removed
              - approval.requested
              - approval.approved
              - approval.rejected
              - account.needs_reconnect
              - account.expires_soon
              - account.paused
              - account.connected
              - account.disconnected
              - account.posts_to_put_back
              - comment.mentioned
              - comment.received
              - share.comment_received
              - review.received
              - media.generated
              - media.generation_failed
              - brand.learned
              - team.member_joined
              - webhook.test
        account_ids:
          type: array
          nullable: true
          items:
            type: integer
          description: Only events about these accounts; null for every account.
        workspace_ids:
          type: array
          nullable: true
          items:
            oneOf:
              - type: integer
              - type: string
                enum:
                  - '*'
          description: >-
            The other workspaces it gets events from, as numbers (an id sent as
            a string of digits comes back as a number), or `["*"]` for every
            workspace the owner has; null for its own workspace alone.
        active:
          type: boolean
          description: 'False when it is turned off: nothing is sent to it.'
        failing_since:
          type: string
          format: date-time
          nullable: true
          description: >-
            When its deliveries started failing; null while they work. After 3
            days failing it is turned off.
        disabled_reason:
          type: string
          nullable: true
          description: >-
            Why PostSyncer turned it off, like `It has been failing for 3
            days.`; null otherwise.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        stats_7d:
          type: object
          description: >-
            Deliveries over the last 7 days: today and the six days before,
            oldest first. A delivery that gave up counts as failed.
          required:
            - sent
            - failed
            - daily
          properties:
            sent:
              type: integer
            failed:
              type: integer
            daily:
              type: array
              items:
                type: object
                required:
                  - date
                  - sent
                  - failed
                properties:
                  date:
                    type: string
                    format: date
                  sent:
                    type: integer
                  failed:
                    type: integer
        last_delivery_at:
          type: string
          format: date-time
          nullable: true
          description: When the latest delivery was made; null before the first.
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthorized401:
      description: No API key, or not a valid one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              summary: No valid API key
              value:
                message: Unauthenticated.
    RateLimited429:
      description: >-
        More than 60 requests in a minute from this key's user (the API and the
        MCP server share the count). Wait `Retry-After` seconds.
      headers:
        Retry-After:
          description: Seconds until requests are allowed again.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Requests allowed a minute.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests left this minute.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: When requests are allowed again, as a Unix timestamp.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            too_many_attempts:
              summary: Too many requests
              value:
                message: Too Many Attempts.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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