API
API Reference
The API supports two authentication methods:
User Token: For regular endpoints, use the
Authorizationheader with the user's token value.Admin Token: For admin endpoints (/admin/**), use the
Authorizationheader with the admin token value (set in WA_ADMIN_TOKEN).
Request Requirements
Content-Type: application/json (JSON-encoded body)
Authentication: Include the
Authorizationheader in all requests.
Admin Endpoints (User Management)
The following admin-only endpoints are used to manage users in the system. All require the Authorization header with the admin token (WA_ADMIN_TOKEN).
List All Users
GET /admin/users
Returns a list of registered users.
Example Request:
curl -s -X GET -H 'Authorization: {{WA_ADMIN_TOKEN}}' http://localhost:8080/admin/usersResponse:
Add User
POST /admin/users
Adds a new user
Example Request:
Response:
User Creation with Optional Proxy and S3 Configuration
You can create a user with optional proxy and S3 storage configuration. All fields are optional and backward compatible. If you do not provide these fields, the user will be created with default settings.
Example Payload
proxyConfig(object, optional):enabled(boolean): Enable proxy for this user.proxyURL(string): Proxy URL (e.g.,socks5://user:pass@host:port).
s3Config(object, optional):enabled(boolean): Enable S3 storage for this user.endpoint(string): S3 endpoint URL.region(string): S3 region.bucket(string): S3 bucket name.accessKey(string): S3 access key.secretKey(string): S3 secret key.pathStyle(boolean): Use path style addressing.publicURL(string): Public URL for accessing files.mediaDelivery(string): Media delivery type (base64,s3, orboth).retentionDays(integer): Number of days to retain files.
If you omit proxyConfig or s3Config, the user will be created without proxy or S3 integration, maintaining full backward compatibility.
Delete User
DELETE /admin/users/{id}
Deletes one user from the system by ID
Example Request:
Response:
Webhook
The following webhook endpoints are used to get or set the webhook that will be called whenever a message or event is received.
For a complete list of available events, see the /webhook/events endpoint below.
Get Available Webhook Events
Retrieves the list of available webhook events.
Endpoint: /webhook/events
Method: GET
Authentication: None (public endpoint)
Parameters:
active(optional): Set to "true" to get only active/implemented events
Response (default):
Response (with ?active=true):
Sets webhook
Configures the webhook to be called using POST whenever a subscribed event occurs.
Endpoint: /webhook
Method: POST
Response:
Gets webhook
Retrieves the configured webhook and subscribed events.
Endpoint: /webhook
Method: GET
Response:
HMAC Configuration
The following HMAC endpoints are used to configure and manage HMAC keys for webhook security. HMAC signatures verify that webhooks are authentic and haven't been tampered with.
Security Notes:
HMAC keys must be at least 32 characters long for security
Once saved, HMAC keys cannot be retrieved or viewed
All webhooks will include an
x-hmac-signatureheader when HMAC is configuredWebhooks are signed using SHA-256 HMAC
Signature Generation by Content-Type:
application/json
Signed data: Raw JSON request body
Verification: Use the exact JSON received
application/x-www-form-urlencoded
Signed data: URL-encoded form string (
key=value&key2=value2)Verification: Reconstruct the form string from received parameters
multipart/form-data (file uploads)
Signed data: JSON representation of form fields (excluding files)
Verification: Create JSON from non-file form fields
Always verify signatures before processing webhooks
Configure HMAC Key
Configures HMAC key for webhook signing to verify webhook authenticity.
Endpoint: /session/hmac/config
Method: POST
Headers:
Authorization: {user_token}Content-Type: application/json
Request Body:
Example Request:
Response:
Error Responses:
400 Bad Request: HMAC key less than 32 characters500 Internal Server Error: Failed to save configuration
Get HMAC Configuration Status
Retrieves HMAC configuration status (does not return the actual key for security reasons).
Endpoint: /session/hmac/config
Method: GET
Headers:
Authorization: {user_token}
Example Request:
Response:
Delete HMAC Configuration
Removes HMAC configuration and disables webhook signing.
Endpoint: /session/hmac/config
Method: DELETE
Headers:
Authorization: {user_token}
Example Request:
Response:
Session
The following session endpoints are used to start a session to Whatsapp servers in order to send and receive messages
Connect
Connects to Whatsapp servers. If is there no existing session it will initiate a QR scan that can be retrieved via the /session/qr endpoint. You can subscribe to different types of messages so they are POSTED to your configured webhook. Available message types to subscribe to are:
Message
ReadReceipt
HistorySync
ChatPresence
If you set Immediate to false, the action will wait 10 seconds to verify a successful login. If Immediate is not set or set to true, it will return immedialty, but you will have to check shortly after the /session/status as your session might be disconnected shortly after started if the session was terminated previously via the phone/device.
Endpoint: /session/connect
Method: POST
Response:
Disconnect
Disconnects from Whatsapp servers, keeping the session active. This means that if you /session/connect again, it will reuse the session and won't require a QR code rescan.
Endpoint: /session/disconnect
Method: POST
Response:
Logout
Disconnects from whatsapp websocket and finishes the session (so it will be required to scan a QR code the next time a connection is initiated)
Endpoint: /session/logout
Method: POST
Response:
Status
Retrieve status (IsConnected means websocket connection is initiated, IsLoggedIn means QR code was scanned and session is ready to receive/send messages)
If its not logged in, you can use the /session/qr endpoint to get the QR code to scan
Endpoint: /session/status
Method: GET
Response:
Gets QR code
Retrieves QR code, session must be connected to Whatsapp servers and logged in must be false in order for the QR code to be generated. The generated code will be returned encoded in base64 embedded format.
Endpoint: /session/qr
Method: GET
Response:
User
The following user endpoints are used to gather information about Whatsapp users.
Gets user details
Gets information for users on Whatsapp
Endpoint: /user/info
Method: POST
Response:
Checks Users
Checks if phone numbers are registered as Whatsapp users
Endpoint: /user/check
Method: POST
Response:
Gets Avatar
Gets information about users profile pictures on WhatsApp, either a thumbnail (Preview=true) or full picture.
Endpoint: /user/avatar
Method: GET
Response:
Gets all contacts
Gets all contacts for the account.
Endpoint: /user/contacts
Method: GET
Response:
Chat
The following chat endpoints are used to send messages or mark them as read or indicating composing/not composing presence. The sample response is listed only once, as it is the same for all message types.
Send Text Message
Sends a text message or reply. For replies, ContextInfo data should be completed with the StanzaID (ID of the message we are replying to), and Participant (user JID we are replying to). If ID is ommited, a random message ID will be generated.
Endpoint: /chat/send/text
Method: POST
Example sending a new message:
Example sending a new message with link preview
Example replying to some message:
Response:
Send Template Message
Sends a template message or reply. Template messages can contain call to action buttons: up to three quick replies, call button, and link button.
Endpoint: /chat/send/template
Method: POST
Send Audio Message
Sends an Audio message. Audio must be in Opus format and base64 encoded in embedded format.
Endpoint: /chat/send/audio
Method: POST
Send Image Message
Sends an Image message. Image must be in png or jpeg and base64 encoded in embedded format. You can optionally specify a text Caption
Endpoint: /chat/send/image
Method: POST
Send Document Message
Sends a Document message. Any mime type can be attached. A FileName must be supplied in the request body. The Document must be passed as octet-stream in base64 embedded format.
Endpoint: /chat/send/document
Method: POST
Send Video Message
Sends a Video message. Video must be in mp4 or 3gpp and base64 encoded in embedded format. You can optionally specify a text Caption and a JpegThumbnail
Endpoint: /chat/send/video
Method: POST
Send Sticker Message
Sends a Sticker message. The API accepts:
Static stickers:
image/webpAnimated stickers:
video/mp4
The sticker data must be base64 encoded in data URI format (e.g., data:image/webp;base64,...).
Endpoint: /chat/send/sticker
Method: POST
Static WebP sticker:
Static WebP sticker with pack metadata:
Animated sticker:
Send Location Message
Sends a Location message. Latitude and Longitude must be passed, with an optional Name
Endpoint: /chat/send/location
Method: POST
Send Contact Message
Sends a Contact message. Both Vcard and Name body parameters are mandatory.
Endpoint: /chat/send/contact
Method: POST
Chat Presence Indication
Sends indication if you are writing/composing a text or audio message to the other party. possible states are "composing" and "paused". if media is set to "audio" it will indicate an audio message is being recorded.
endpoint: /chat/presence
method: POST
Mark message(s) as read
Indicates that one or more messages were read. Id is an array of messages Ids. The endpoint now supports two methods for chat identification to ensure backward compatibility:
New Standard: Use ChatPhone and SenderPhone (recommended).
Legacy: Use Chat and Sender (accepts full JID format).
Priority Logic
The API processes the IDs using the following priority: ChatPhone > Chat (and SenderPhone > Sender).
endpoint: /chat/markread
method: POST
React to messages
Sends a reaction for an existing message. Id is the message Id to react to, if its your own message, prefix the Id with the string 'me:'
endpoint: /chat/react
method: POST
Download Image
Downloads an Image from a message and retrieves it Base64 media encoded. Required request parameters are: Url, MediaKey, Mimetype, FileSHA256 and FileLength
endpoint: /chat/downloadimage
method: POST
Download Video
Downloads a Video from a message and retrieves it Base64 media encoded. Required request parameters are: Url, MediaKey, Mimetype, FileSHA256 and FileLength
endpoint: /chat/downloadvideo
method: POST
Download Audio
Downloads an Audio from a message and retrieves it Base64 media encoded. Required request parameters are: Url, MediaKey, Mimetype, FileSHA256 and FileLength
endpoint: /chat/downloadaudio
method: POST
Download Document
Downloads a Document from a message and retrieves it Base64 media encoded. Required request parameters are: Url, MediaKey, Mimetype, FileSHA256 and FileLength
endpoint: /chat/downloaddocument
method: POST
Group
The following group endpoints are used to gather information or perfrom actions in chat groups.
List subscribed groups
Returns complete list of subscribed groups
endpoint: /group/list
method: GET
Response:
Get group invite link
Gets the invite link for a group
endpoint: /group/invitelink
method: GET
Response:
Gets group information
Retrieves information about a specific group
endpoint: /group/info
method: GET
Response:
Changes group photo
Allows you to change a group photo/image. WhatsApp only accepts JPEG format for group photos.
endpoint: /group/photo
method: POST
Parameters:
GroupJID: The JID of the groupImage: Base64 encoded JPEG image data with data URL format (must be "data:image/jpeg;base64,...")
Important Notes:
Only JPEG format is supported (WhatsApp requirement)
Image will be automatically resized if too large
Transparent images will be converted to JPEG with white background
Response:
Changes group name
Allows you to change a group name
endpoint: /group/name
method: POST
Response:
Create group
Creates a new WhatsApp group with specified name and participants
endpoint: /group/create
method: POST
Response:
Set group locked status
Configures whether only admins can modify group info (locked) or all participants can modify (unlocked)
endpoint: /group/locked
method: POST
Response:
Set disappearing timer
Configures ephemeral/disappearing messages for the group. Messages will automatically disappear after the specified duration.
endpoint: /group/ephemeral
method: POST
Valid duration values:
"24h"- 24 hours"7d"- 7 days"90d"- 90 days"off"- Disable disappearing messages
Response:
Remove group photo
Removes the current photo/image from the specified WhatsApp group
endpoint: /group/photo/remove
method: POST
Response:
S3 Storage Integration for Genfity Wa
Overview
Genfity Wa now supports S3-compatible storage for media files, allowing you to store WhatsApp media (images, videos, audio, and documents) in cloud storage services instead of or in addition to base64 encoding in webhooks.
Features
Multi-tenant Support: Each user can configure their own S3 storage
Multiple Providers: Support for AWS S3, MinIO, Backblaze B2, and other S3-compatible services
Flexible Delivery: Choose between base64, S3 URL, or both in webhooks
Automatic Organization: Files are organized by user, contact, date, and media type
Public Access: Media files are stored with public-read permissions for easy preview
Retention Management: Configurable retention period with automatic expiration
CDN Support: Option to use custom public URLs for CDN integration
API Endpoints
Configure S3 Storage
Configure S3 storage settings for the authenticated user.
Request Body:
Parameters:
enabled: Enable/disable S3 storageendpoint: S3 endpoint URL (leave empty for AWS S3)region: S3 regionbucket: S3 bucket nameaccess_key: S3 access key IDsecret_key: S3 secret access keypath_style: Use path-style URLs (required for MinIO)public_url: Custom public URL for accessing files (optional)media_delivery: Delivery method - "base64", "s3", or "both"retention_days: Days to retain files (0 for no expiration)
Get S3 Configuration
Retrieve current S3 configuration (access key is masked).
Response:
Test S3 Connection
Test S3 connection with current configuration.
Response:
Delete S3 Configuration
Remove S3 configuration and revert to base64-only delivery.
S3 Provider Examples
AWS S3
MinIO
Backblaze B2
File Organization
Media files are stored in S3 with the following structure:
Example:
Webhook Payload
When S3 is enabled, webhook payloads will include S3 information based on the media_delivery setting:
S3 Only (media_delivery: "s3")
media_delivery: "s3")Both S3 and Base64 (media_delivery: "both")
media_delivery: "both")Bucket Policy
Ensure your S3 bucket has the appropriate policy for public read access:
Important Notes
Security: Store S3 credentials securely. They are encrypted in the database but should still be treated as sensitive.
Costs: S3 storage and bandwidth costs apply based on your provider's pricing.
Performance: S3 upload is synchronous. Large files may slightly delay webhook delivery.
Fallback: If S3 upload fails, the webhook is still sent (without S3 data if
media_deliveryis "s3" only).Retention: Files are automatically deleted after the retention period if set. Use 0 for permanent storage.
Public Access: Files are stored with public-read permissions. Do not use this for sensitive data without additional security measures.
Migration Guide
To migrate from base64-only to S3 storage:
Configure S3 with
media_delivery: "both"initiallyUpdate your webhook handler to support both formats
Test thoroughly with various media types
Switch to
media_delivery: "s3"once confirmed workingUpdate webhook handler to use S3 URLs exclusively
Troubleshooting
Connection Test Fails
Verify credentials are correct
Check bucket exists and is accessible
Ensure region is correct
For MinIO, ensure
path_style: trueis set
Files Not Accessible
Check bucket policy allows public read
Verify CORS settings if accessing from browser
Ensure
public_urlis correct if using CDN
Webhook Missing S3 Data
Check
media_deliverysettingVerify S3 is enabled
Check logs for upload errors
Test S3 connection
Webhook format configuration
Starting from version X.X.X, you can choose the format for sending webhook data using the WEBHOOK_FORMAT environment variable.
Available options
form(default): Sends data asapplication/x-www-form-urlencoded, with the JSON in thejsonDatafield and the token in thetokenfield.json: Sends data asapplication/json, with the full event JSON as the body and thetokenfield included.
How to configure
In your terminal, set the variable before starting the service:
Payload examples
Form mode (default):
JSON mode:
Notes
The
formmode ensures compatibility with legacy or older webhook systems.The
jsonmode is recommended for modern integrations and easier backend parsing.If you do not set the variable, the system will use
formmode by default.
Last updated