Skip to content

docs: add custom headers and JWT documentation for webhooks#22

Open
jordanrendric wants to merge 2 commits intoEvolutionAPI:mainfrom
jordanrendric:main
Open

docs: add custom headers and JWT documentation for webhooks#22
jordanrendric wants to merge 2 commits intoEvolutionAPI:mainfrom
jordanrendric:main

Conversation

@jordanrendric
Copy link

@jordanrendric jordanrendric commented Mar 25, 2026

Summary

  • Added documentation for the headers field in webhook configuration (PT and EN)
  • Documented all supported authentication types: Bearer Token, API Key, Basic Auth, and custom headers
  • Documented the special jwt_key property for automatic JWT (HS256) token generation
  • Updated OpenAPI v2 spec to include headers field in webhook/set request/response, webhook/find response, and instance/create request

Files changed

  • v2/pt/configuration/webhooks.mdx — New "Headers Customizados" section
  • v2/en/configuration/webhooks.mdx — New "Custom Headers" section
  • openapi/openapi-v2.json — Added headers property with description, type, and examples

Context

The Evolution API already supports custom headers in outgoing webhooks (since migration 20240906202019_add_headers_on_webhook_config), but this feature was not documented. This PR adds comprehensive documentation covering configuration via /event/webhook/set and /instance/create, all supported header types, and the automatic JWT signing feature.

Summary by Sourcery

Document custom webhook headers support and automatic JWT generation in both English and Portuguese docs, and align the OpenAPI v2 specification with the existing webhook headers feature.

Enhancements:

  • Clarify webhook configuration parameters by documenting the optional headers and base64 fields in both English and Portuguese guides and updating corresponding OpenAPI v2 schema to expose webhook headers support.

Documentation:

  • Add English documentation for configuring custom webhook headers, including supported auth patterns and automatic JWT generation via jwt_key, for webhook setup and instance creation.
  • Add Portuguese documentation for configuring custom webhook headers, including supported auth patterns and automatic JWT generation via jwt_key, for webhook setup and instance creation.

Document the `headers` field in webhook configuration, including support
for static tokens (Bearer, API Key, Basic Auth) and automatic JWT
generation via the special `jwt_key` property. Updated PT and EN docs
and OpenAPI v2 spec for webhook/set, webhook/find, and instance/create.
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 25, 2026

Reviewer's Guide

Documents support for custom HTTP headers (including an automatic JWT feature) in webhook configuration, updates both EN/PT webhook docs with usage examples for /event/webhook/set and /instance/create, and extends the OpenAPI v2 spec to expose the new headers field and base64 flag on relevant webhook and instance operations.

Sequence diagram for webhook delivery with custom headers and automatic JWT

sequenceDiagram
    actor Developer
    participant EvolutionAPI
    participant WebhookConfigStore
    participant JWTSigner
    participant ExternalWebhookServer

    Developer->>EvolutionAPI: POST /event/webhook/set/{instanceName}\nwebhook.enabled, url, headers{jwt_key, other}
    EvolutionAPI->>WebhookConfigStore: Save webhook config with headers
    WebhookConfigStore-->>EvolutionAPI: Config stored

    loop For each event
        EvolutionAPI->>WebhookConfigStore: Load webhook config for instance
        WebhookConfigStore-->>EvolutionAPI: enabled, url, headers
        alt jwt_key is present in headers
            EvolutionAPI->>JWTSigner: Sign JWT with secret = headers.jwt_key\npayload(iat, exp, app, action)
            JWTSigner-->>EvolutionAPI: jwt_token
            EvolutionAPI->>EvolutionAPI: Remove jwt_key from headers
            EvolutionAPI->>EvolutionAPI: Set Authorization = Bearer jwt_token
        else jwt_key not present
            EvolutionAPI->>EvolutionAPI: Use configured static headers
        end
        EvolutionAPI->>ExternalWebhookServer: POST webhook request with final headers and payload
        ExternalWebhookServer-->>EvolutionAPI: 2xx/4xx/5xx response
    end
Loading

File-Level Changes

Change Details Files
Document webhook custom headers and authentication patterns in the English docs, including automatic JWT generation and instance-creation support.
  • Extend webhook configuration parameters table to include headers object and base64 flag.
  • Add a dedicated Custom Headers section with examples for Bearer, API Key, Basic Auth, and multiple headers usage.
  • Describe the jwt_key convention for automatic HS256 JWT generation, payload structure, expiry, and how it is sent via Authorization header.
  • Show how to configure headers on /event/webhook/set and /instance/create payloads with concrete JSON examples.
  • Clarify that environment-variable-based global webhooks do not support custom headers and must be configured per instance via API.
  • Update webhook/find response example to include headers in the returned configuration.
v2/en/configuration/webhooks.mdx
Add a localized Portuguese version of the custom headers and JWT documentation for webhooks, mirroring the English content.
  • Update webhook parameters table to include headers object and base64 flag with PT descriptions.
  • Introduce Headers Customizados section with configuration examples for /event/webhook/set and /instance/create.
  • Document supported authentication types (Bearer Token, API Key, Basic Auth) and multiple header combinations in PT.
  • Explain JWT Automático via jwt_key, including token generation, claims, expiration, and Authorization header behaviour.
  • State in PT that global webhooks configured via environment variables do not support custom headers and require per-instance API configuration.
  • Extend webhook/find response example to show headers in the returned configuration.
v2/pt/configuration/webhooks.mdx
Expose the headers field (and any related flags like base64) in the OpenAPI v2 specification for webhook and instance endpoints.
  • Add headers property to the webhook object schema used by /event/webhook/set requests and responses.
  • Include headers in the webhook section of /event/webhook/find responses so clients see configured custom headers in the API schema.
  • Allow headers configuration on /instance/create by updating the instance creation request schema.
  • Ensure property descriptions and example values in the OpenAPI spec match the new documentation for custom headers usage.
openapi/openapi-v2.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The docs and examples use three different property names for the same setting (webhook_by_events in the parameter table, byEvents in request examples, and webhookByEvents in responses); consider standardizing the naming and explicitly calling out the difference between request/response fields to avoid confusion for API consumers.
  • In the jwt_key section, you might want to add a short note that this value must be treated as a secret (e.g., not embedded in front-end code or shared publicly) since it is used to sign JWTs, to help prevent common misuses.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The docs and examples use three different property names for the same setting (`webhook_by_events` in the parameter table, `byEvents` in request examples, and `webhookByEvents` in responses); consider standardizing the naming and explicitly calling out the difference between request/response fields to avoid confusion for API consumers.
- In the `jwt_key` section, you might want to add a short note that this value must be treated as a secret (e.g., not embedded in front-end code or shared publicly) since it is used to sign JWTs, to help prevent common misuses.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…ey security warning

- Standardize parameter names in tables to match actual API request fields (byEvents, base64)
- Note that response fields use different names (webhookByEvents, webhookBase64)
- Add security warning about treating jwt_key as a secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant