Skip to content

Latest commit

 

History

History
86 lines (65 loc) · 3.02 KB

webhooks.md

File metadata and controls

86 lines (65 loc) · 3.02 KB
id
webhooks

Webhooks

Webhooks are a way for an app to send automated real-time notifications to another app when a specific event occurs. In Manifest, there are 8 predefined events where you can hook HTTP requests.

Webhooks are useful to connect other applications or to trigger a micro-service like notifying someone or update a file.

Syntax

entities:
  # You can attach one or several webhooks to each entity event.
  Cat 😺:
    properties:
      - name
    hooks:
      beforeCreate:
        - { url: 'https://my-webhook.com' }

  Dog 🐶:
    properties:
      - name
    hooks:
      afterDelete:
        # Pass .env variables with ${} interpolation.
        - {
            url: 'https://another-webhook.com',
            headers: { authorization: 'Bearer ${API_KEY}' }
          }
        # Specific HTTP method.
        - { url: 'https://another-one.com', method: 'PATCH' }

Webhook params

You can pass arguments using the long syntax:

Option Default Type Description
url* - string The URL of your webhook
method POST HTTP Method The HTTP method of the request
headers {} object Optional headers of the request. Use ${MY_DOTENV_VAR} syntax to use dotenv variables

Available HTTP Methods are GET, POST, PUT, PATCH and DELETE.

:::note

Manifest does not enforce HTTP request success or failure; the lifecycle process continues regardless.

:::

Webhook body

Manifest attaches a JSON body with key information about the record concerned to the webhook HTTP request.

The main structure of the body of the triggered HTTP requests will remain the same and only the record value will change: on before events the record will contain your payload, whereas in after requests, the record value will reflect the item after the operation.

This is the structure of the body:

{
  "event": "beforeUpdate",
  "createdAt": "2025-01-22T13:38:48.399Z",
  "entity": "posts",
  "record": {
    "title": "my title",
    "content": "my content"
  }
}

Hook events

This is the list and description of the 8 hook events available. All of them are related to an entity

Name Description
beforeCreate Before creating a record
afterCreate After creating a record
beforeUpdate Before updating a record
afterUpdate After updating a record
beforeDelete Before deleting a record
afterDelete After deleting a record