Create a webhook
Register a new webhook on your postpress account. The body is a discriminated union on `source`: pick the family of events you want to receive (`messaging`, `users`, `account_status`, `email`, `email_tracking`, or `calendar_event`) and the available `events` and `data.key` values change accordingly.
Authorization
Request body
Every variant accepts the same envelope of common fields. The `source` discriminator decides which `events` enum and which `data.key` enum apply.
(variant) Messaging webhookobject(variant) Messaging webhook object
sourcestringmessagingrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringsmessage_receivedmessage_readmessage_reactionmessage_editedmessage_deletedmessage_deliveredheadersarray of objectsheaders object
keystringrequiredvaluestringrequireddataarray of objectsdata object
namestringrequiredkeystringrequiredaccount_idaccount_typeaccount_infochat_idtimestampwebhook_namemessage_idmessagereactionreaction_senderread_bysenderis_senderattendeesattachmentssubjectprovider_chat_idprovider_message_idis_eventchat_pinnedquotedis_forwardedchat_content_typemessage_typeis_groupfolder(variant) Users webhookobject(variant) Users webhook object
sourcestringusersrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringsnew_relationheadersarray of objectsheaders object
keystringrequiredvaluestringrequireddataarray of objectsdata object
namestringrequiredkeystringrequiredaccount_idaccount_typewebhook_nametimestampuser_provider_iduser_full_nameuser_public_identifieruser_profile_urluser_picture_url(variant) Account status webhookobject(variant) Account status webhook object
sourcestringaccount_statusrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringscreation_successcreation_faildeletedreconnectedsync_successstoppedokconnectingerrorcredentialspermissionsheadersarray of objectsheaders object
keystringrequiredvaluestringrequired(variant) Email webhookobject(variant) Email webhook object
sourcestringemailrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringsmail_sentmail_receivedmail_movedheadersarray of objectsheaders object
keystringrequiredvaluestringrequireddataarray of objectsdata object
namestringrequiredkeystringrequiredemail_idaccount_idwebhook_namedatefrom_attendeeto_attendeescc_attendeesbcc_attendeesreply_to_attendeessubjectbodybody_plainmessage_idprovider_idtracking_idread_dateis_completein_reply_tohas_attachmentsattachmentsfoldersroleoriginthread_iddeprecated_id(variant) Email tracking webhookobject(variant) Email tracking webhook object
sourcestringemail_trackingrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringsmail_openedmail_link_clickedheadersarray of objectsheaders object
keystringrequiredvaluestringrequireddataarray of objectsdata object
namestringrequiredkeystringrequiredevent_idtracking_idtypedateemail_idaccount_idipuser_agenturllabelcustom_domain(variant) Calendar event webhookobject(variant) Calendar event webhook object
sourcestringcalendar_eventrequiredrequest_urlstringrequirednamestringformatstringjsonformenabledbooleanaccount_idsarray of stringseventsarray of stringscalendar_event_createdcalendar_event_updatedcalendar_event_deletedheadersarray of objectsheaders object
keystringrequiredvaluestringrequireddataarray of objectsdata object
namestringrequiredkeystringrequiredaccount_idaccount_typeidical_uidmaster_event_idcalendar_idcreated_atupdated_attitlebodylocationis_cancelledis_all_dayis_attendees_list_hiddenattendeesstartendrecurrenceorganizerconference_idconferencevisibilitytransparencyevent_typecolorResponse 201 Created
objectstringWebhookCreatedrequiredwebhook_idstringrequiredExample request
curl --request POST \
--url 'https://api.postpress.ai/api/v1/webhooks' \
--header 'X-API-KEY: pp_live_...' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"source": "messaging",
"request_url": "https://app.example.com/hooks/postpress",
"name": "Inbound DMs - production",
"format": "json",
"enabled": true,
"account_ids": ["acc_linkedin_01HXYZ4QK3WJ8FN3M6QH7TZ8GR"],
"events": ["message_received", "message_reaction"],
"headers": [{ "key": "Authorization", "value": "Bearer s3cr3t" }],
"data": [
{ "name": "from", "key": "sender" },
{ "name": "body", "key": "message" },
{ "name": "chat", "key": "chat_id" },
{ "name": "subject", "key": "subject" }
]
}'Example response
{
"object": "WebhookCreated",
"webhook_id": "wh_01HXYZ4QK3WJ8FN3M6QH7TZ8GR"
}Errors
Every error response follows the same envelope:
400 Bad Request8 types
The body is malformed or a field is invalid.
errors/invalid_parameters- One or more fields are invalid (e.g. unknown `source`, `data.key` not allowed for this `source`).errors/malformed_request- The request is malformed.errors/content_too_large- The request is too large.errors/invalid_url- `request_url` is not a valid URL.errors/too_many_characters- A string field exceeds the allowed length.errors/unescaped_characters- A field contains characters that must be encoded.errors/missing_parameters- A required field (`request_url`, `source`) is missing.errors/limit_too_high- A list field exceeds the allowed maximum.
401 Unauthorized13 types
API key is missing, expired, or otherwise invalid.
errors/missing_credentials- API key is missing from the request.errors/invalid_credentials- API key is invalid.errors/expired_credentials- API key has expired. Rotate it from the dashboard.errors/insufficient_privileges- This resource is out of your API-key scopes.errors/multiple_sessions- Multiple sessions detected on the same account.errors/wrong_account- The credentials do not match the correct account.errors/invalid_proxy_credentials- The provided proxy credentials are invalid.errors/invalid_checkpoint_solution- The checkpoint resolution did not pass successfully.errors/checkpoint_error- The checkpoint does not appear to be resolvable.errors/expired_link- This link has expired. Generate a new one.errors/disconnected_account- The account is disconnected from the provider service.errors/disconnected_feature- The feature you're trying to reach is disconnected.errors/invalid_credentials_but_valid_account_imap- IMAP/SMTP credentials are invalid but the account is otherwise valid.
403 Forbidden9 types
Authenticated but the action is not allowed.
errors/insufficient_permissions- Insufficient permissions to perform the request.errors/account_restricted- The account has been restricted by the provider.errors/account_mismatch- This action cannot be done with your account.errors/unknown_authentication_context- An additional step seems necessary to complete login.errors/session_mismatch- Token user id does not match client session id.errors/feature_not_subscribed- The requested feature has not been subscribed.errors/subscription_required- A subscription is required to use this feature.errors/resource_access_restricted- You don't have access to this resource.errors/action_required- An additional step is required.
404 Not Found2 types
One of the targeted resources does not exist.
errors/resource_not_found- An entry in `account_ids` does not match any connected account.errors/invalid_resource_identifier- An account id is malformed.
500 Internal Server Error3 types
Something went wrong on our side.
errors/unexpected_error- Something went wrong.errors/provider_error- The provider is experiencing operational problems. Retry later.errors/authentication_intent_error- The current authentication intent was killed after failure.
503 Service Unavailable5 types
postpress is temporarily unable to handle the request.
errors/no_client_session- No client session is currently running.errors/no_channel- No channel to client session.errors/no_handler- Handler missing for that request.errors/network_down- Network is down on the server side. Retry shortly.errors/service_unavailable- Service temporarily unavailable. Retry later.
504 Gateway Timeout1 types
The upstream provider did not respond in time.
errors/request_timeout- Request timed out. Retry, and contact support if it persists.