docs: add custom headers and JWT documentation for webhooks#22
Open
jordanrendric wants to merge 2 commits intoEvolutionAPI:mainfrom
Open
docs: add custom headers and JWT documentation for webhooks#22jordanrendric wants to merge 2 commits intoEvolutionAPI:mainfrom
jordanrendric wants to merge 2 commits intoEvolutionAPI:mainfrom
Conversation
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.
Reviewer's GuideDocuments 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 JWTsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The docs and examples use three different property names for the same setting (
webhook_by_eventsin the parameter table,byEventsin request examples, andwebhookByEventsin responses); consider standardizing the naming and explicitly calling out the difference between request/response fields to avoid confusion for API consumers. - In the
jwt_keysection, 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1 task
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
headersfield in webhook configuration (PT and EN)jwt_keyproperty for automatic JWT (HS256) token generationheadersfield inwebhook/setrequest/response,webhook/findresponse, andinstance/createrequestFiles changed
v2/pt/configuration/webhooks.mdx— New "Headers Customizados" sectionv2/en/configuration/webhooks.mdx— New "Custom Headers" sectionopenapi/openapi-v2.json— Addedheadersproperty with description, type, and examplesContext
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/setand/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:
Documentation: