curl --request PUT \
--url https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fields": [
{
"key": "email",
"type": "string",
"required": true
},
{
"key": "plan",
"type": "enum",
"required": false,
"enumValues": [
"free",
"pro"
],
"fallbackValue": "free",
"description": "Billing plan at signup time."
},
{
"key": "order",
"type": "object",
"required": false,
"children": [
{
"key": "total",
"type": "float",
"required": true
}
]
}
]
}
'import requests
url = "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract"
payload = { "fields": [
{
"key": "email",
"type": "string",
"required": True
},
{
"key": "plan",
"type": "enum",
"required": False,
"enumValues": ["free", "pro"],
"fallbackValue": "free",
"description": "Billing plan at signup time."
},
{
"key": "order",
"type": "object",
"required": False,
"children": [
{
"key": "total",
"type": "float",
"required": True
}
]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fields: [
{key: 'email', type: 'string', required: true},
{
key: 'plan',
type: 'enum',
required: false,
enumValues: ['free', 'pro'],
fallbackValue: 'free',
description: 'Billing plan at signup time.'
},
{
key: 'order',
type: 'object',
required: false,
children: [{key: 'total', type: 'float', required: true}]
}
]
})
};
fetch('https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'fields' => [
[
'key' => 'email',
'type' => 'string',
'required' => true
],
[
'key' => 'plan',
'type' => 'enum',
'required' => false,
'enumValues' => [
'free',
'pro'
],
'fallbackValue' => 'free',
'description' => 'Billing plan at signup time.'
],
[
'key' => 'order',
'type' => 'object',
'required' => false,
'children' => [
[
'key' => 'total',
'type' => 'float',
'required' => true
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract"
payload := strings.NewReader("{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"subjectKind": "trigger",
"subjectId": "tri_signup",
"source": "stored",
"typeName": "UserSignedUpPayload",
"contractHash": "22545d11e1d174ba0717ed37c9c4b460c96bed51ae31ea0af18266ebba30f76a",
"version": 2,
"enforcement": "off",
"fields": [
{
"key": "email",
"type": "string",
"required": true
},
{
"key": "plan",
"type": "enum",
"required": false,
"enumValues": [
"free",
"pro"
],
"fallbackValue": "free"
},
{
"key": "order",
"type": "object",
"required": false,
"children": [
{
"key": "total",
"type": "float",
"required": true
}
]
}
]
}{
"error": {
"code": "INVALID_REQUEST",
"type": "invalid_request",
"message": "Trigger contracts must declare a top-level required \"email\" string field.",
"suggestion": "Fix the contract fields and retry; POST …/contract/validate never writes and returns per-field verdicts.",
"docs": "https://docs.brew.new/api-reference/api/errors",
"param": "fields"
}
}{
"error": {
"code": "INVALID_API_KEY",
"type": "authentication_error",
"message": "The provided API key is invalid.",
"suggestion": "Check the API key format and retry with a valid active key.",
"docs": "https://docs.brew.new/api-reference/api/authentication"
}
}{
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"type": "authorization_error",
"message": "The caller does not have the required permission.",
"suggestion": "Use an API key or session with the required permission.",
"docs": "https://docs.brew.new/api-reference/api/authentication",
"param": "automations"
}
}{
"error": {
"code": "TRIGGER_EVENT_NOT_FOUND",
"type": "not_found",
"message": "Trigger event 'tri_xxx' was not found.",
"suggestion": "List triggers with GET /v1/automations/triggers.",
"docs": "https://docs.brew.new/api-reference/api/errors",
"param": "triggerEventId"
}
}{
"error": {
"code": "RATE_LIMITED",
"type": "rate_limit",
"message": "Too many requests.",
"suggestion": "Wait for the retry window before sending another request.",
"docs": "https://docs.brew.new/api-reference/api/rate-limits",
"retryAfter": 42
}
}{
"error": {
"code": "INTERNAL_ERROR",
"type": "internal_error",
"message": "An unexpected error occurred.",
"suggestion": "Retry the request. If it keeps failing, contact support.",
"docs": "https://docs.brew.new/api-reference/api/errors"
}
}Declare a trigger payload contract
Declares the stored payload contract for the trigger, changes how it is enforced, or both — in one call. fields is optional, so flipping enforcement never means re-sending the whole tree. The whole tree is validated structurally BEFORE any write — unknown-typed nodes are refused (declare a concrete type), keys must be unique per level, and an object field must declare at least one child. Trigger contracts MUST keep a top-level { key: "email", type: "string", required: true } field so automations can resolve a recipient.
The contract version bumps only when the behavioral surface changes (keys, types, required, fallbacks — not descriptions or examples). Declaring a contract never changes fire behavior by itself: enforcement stays off until explicitly enabled.
Responds with the same body a follow-up GET …/contract would return.
curl --request PUT \
--url https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fields": [
{
"key": "email",
"type": "string",
"required": true
},
{
"key": "plan",
"type": "enum",
"required": false,
"enumValues": [
"free",
"pro"
],
"fallbackValue": "free",
"description": "Billing plan at signup time."
},
{
"key": "order",
"type": "object",
"required": false,
"children": [
{
"key": "total",
"type": "float",
"required": true
}
]
}
]
}
'import requests
url = "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract"
payload = { "fields": [
{
"key": "email",
"type": "string",
"required": True
},
{
"key": "plan",
"type": "enum",
"required": False,
"enumValues": ["free", "pro"],
"fallbackValue": "free",
"description": "Billing plan at signup time."
},
{
"key": "order",
"type": "object",
"required": False,
"children": [
{
"key": "total",
"type": "float",
"required": True
}
]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fields: [
{key: 'email', type: 'string', required: true},
{
key: 'plan',
type: 'enum',
required: false,
enumValues: ['free', 'pro'],
fallbackValue: 'free',
description: 'Billing plan at signup time.'
},
{
key: 'order',
type: 'object',
required: false,
children: [{key: 'total', type: 'float', required: true}]
}
]
})
};
fetch('https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'fields' => [
[
'key' => 'email',
'type' => 'string',
'required' => true
],
[
'key' => 'plan',
'type' => 'enum',
'required' => false,
'enumValues' => [
'free',
'pro'
],
'fallbackValue' => 'free',
'description' => 'Billing plan at signup time.'
],
[
'key' => 'order',
'type' => 'object',
'required' => false,
'children' => [
[
'key' => 'total',
'type' => 'float',
'required' => true
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract"
payload := strings.NewReader("{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://brew.new/api/v1/automations/triggers/{triggerEventId}/contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fields\": [\n {\n \"key\": \"email\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"key\": \"plan\",\n \"type\": \"enum\",\n \"required\": false,\n \"enumValues\": [\n \"free\",\n \"pro\"\n ],\n \"fallbackValue\": \"free\",\n \"description\": \"Billing plan at signup time.\"\n },\n {\n \"key\": \"order\",\n \"type\": \"object\",\n \"required\": false,\n \"children\": [\n {\n \"key\": \"total\",\n \"type\": \"float\",\n \"required\": true\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"subjectKind": "trigger",
"subjectId": "tri_signup",
"source": "stored",
"typeName": "UserSignedUpPayload",
"contractHash": "22545d11e1d174ba0717ed37c9c4b460c96bed51ae31ea0af18266ebba30f76a",
"version": 2,
"enforcement": "off",
"fields": [
{
"key": "email",
"type": "string",
"required": true
},
{
"key": "plan",
"type": "enum",
"required": false,
"enumValues": [
"free",
"pro"
],
"fallbackValue": "free"
},
{
"key": "order",
"type": "object",
"required": false,
"children": [
{
"key": "total",
"type": "float",
"required": true
}
]
}
]
}{
"error": {
"code": "INVALID_REQUEST",
"type": "invalid_request",
"message": "Trigger contracts must declare a top-level required \"email\" string field.",
"suggestion": "Fix the contract fields and retry; POST …/contract/validate never writes and returns per-field verdicts.",
"docs": "https://docs.brew.new/api-reference/api/errors",
"param": "fields"
}
}{
"error": {
"code": "INVALID_API_KEY",
"type": "authentication_error",
"message": "The provided API key is invalid.",
"suggestion": "Check the API key format and retry with a valid active key.",
"docs": "https://docs.brew.new/api-reference/api/authentication"
}
}{
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"type": "authorization_error",
"message": "The caller does not have the required permission.",
"suggestion": "Use an API key or session with the required permission.",
"docs": "https://docs.brew.new/api-reference/api/authentication",
"param": "automations"
}
}{
"error": {
"code": "TRIGGER_EVENT_NOT_FOUND",
"type": "not_found",
"message": "Trigger event 'tri_xxx' was not found.",
"suggestion": "List triggers with GET /v1/automations/triggers.",
"docs": "https://docs.brew.new/api-reference/api/errors",
"param": "triggerEventId"
}
}{
"error": {
"code": "RATE_LIMITED",
"type": "rate_limit",
"message": "Too many requests.",
"suggestion": "Wait for the retry window before sending another request.",
"docs": "https://docs.brew.new/api-reference/api/rate-limits",
"retryAfter": 42
}
}{
"error": {
"code": "INTERNAL_ERROR",
"type": "internal_error",
"message": "An unexpected error occurred.",
"suggestion": "Retry the request. If it keeps failing, contact support.",
"docs": "https://docs.brew.new/api-reference/api/errors"
}
}Authorizations
Send your Brew API key as Authorization: Bearer brew_xxx.
Headers
The brand this request acts on. REQUIRED for organization-scoped credentials (otherwise 400 BRAND_ID_REQUIRED — there is no default brand); list ids with GET /v1/brands. Brand-scoped credentials may omit it, and sending a different brand returns 403 BRAND_SCOPE_MISMATCH. A brand outside your organization returns 404 BRAND_NOT_FOUND.
1 - 64Path Parameters
Trigger id returned by POST /v1/automations/triggers (integration triggers use composite ids — URL-encode the colons).
1 - 256"tri_signup"
Body
Response
Stored. The contract as a follow-up GET would return it.
trigger 1stored, derived_from_schema, derived_from_template 1json, ts, zod, jsonschema, skill 64x >= 1off, prune, strict fresh, stale Show child attributes
Show child attributes
Was this page helpful?