Skip to main content

External system integrations with webhooks

You can easily integrate with external systems using webhooks. Use these examples to integrate with one of the listed systems or to create a custom configuration.

tip

Read this document to learn more about configuring hooks and webhooks.

Mailchimp

Use this configuration to send emails to users with Mailchimp

  - hook: web_hook
config:
url: https://mandrillapp.com/api/1.0/messages/send
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET

Request body Jsonnet:

info

For Mailchimp, you must pass the API key in the request body. This means you must include it in the Jsonnet snippet.

Mailchimp request body
function(ctx) {
key: "<Your-Api-Key>",
message: {
from_email: "[email protected]",
subject: "Hello from Ory",
text: "Welcome to Ory! Have fun and happy hacking!",
to: [
{
email: ctx.identity.verifiable_addresses[0].value,
type: "to"
}
]
}
}

HubSpot

Use this configuration to add customers to your HubSpot contact list:

note

This setup creates a non-blocking webhook. Click here to learn more.

  - hook: web_hook
config:
response:
ignore: true
auth:
type: api_key
config:
name: Authorization
value: "Bearer <YOUR_API_KEY_HERE>"
in: header
url: "https://api.hubapi.com/crm/v3/objects/contacts"
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET

Request body Jsonnet:

HubSpot request body
function(ctx)
{
properties: {
email: ctx.identity.traits.email,
firstname: ctx.identity.traits.name,
// ...
},
}

Segment

Use this configuration to call Segment's Identify API and collect user-specific usage data:

- hook: web_hook
config:
auth:
type: "basic_auth"
config:
user: <segment_write_key>
password: ""
url: "https://api.segment.io/v1/identify"
method: POST
# Encode the Jsonnet with Base64 and add the encoded string to 'body'.
body: base64://ENCODED_JSONNET

Request body Jsonnet:

Segment request body
function(ctx)    {
userId: ctx.identity.id,
traits: {
email: ctx.identity.traits.email,
name: ctx.identity.traits.name,
newsletterConsent: ctx.identity.traits.consent.newsletter,
},
}