SDK code examples
Copy-paste curl, TypeScript, and Python snippets for the most-used endpoints.
Every example below authenticates with a bearer key against https://app.pact.place. Set PACT_API_KEY in your environment first — see Get an API key in 60 seconds.
These snippets are generated from the same OpenAPI spec that powers the API reference, so they stay in step with the live surface. Path ids and request bodies use placeholder values — the reference is the authoritative field list.
List accounts
curl "https://app.pact.place/v1/companies?limit=25&offset=0" \
-H "Authorization: Bearer $PACT_API_KEY"
const res = await fetch("https://app.pact.place/v1/companies?limit=25&offset=0", {
headers: { Authorization: `Bearer ${process.env.PACT_API_KEY}` },
});
const page = await res.json();
import os, requests
res = requests.get(
"https://app.pact.place/v1/companies",
params={"limit": 25, "offset": 0},
headers={"Authorization": f"Bearer {os.environ['PACT_API_KEY']}"},
timeout=10,
)
page = res.json()
Create a contact
curl -X POST https://app.pact.place/v1/contacts \
-H "Authorization: Bearer $PACT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Dana Lee", "email": "[email protected]" }'
const res = await fetch("https://app.pact.place/v1/contacts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PACT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ name: "Dana Lee", email: "[email protected]" }),
});
const contact = await res.json();
import os, requests
res = requests.post(
"https://app.pact.place/v1/contacts",
json={"name": "Dana Lee", "email": "[email protected]"},
headers={"Authorization": f"Bearer {os.environ['PACT_API_KEY']}"},
timeout=10,
)
contact = res.json()
Create a webhook subscription
curl -X POST https://app.pact.place/v1/webhooks/subscriptions \
-H "Authorization: Bearer $PACT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "CRM sync",
"url": "https://api.example.com/pact-webhook",
"event_types": ["contact.created", "deal.*"]
}'
const res = await fetch("https://app.pact.place/v1/webhooks/subscriptions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PACT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "CRM sync",
url: "https://api.example.com/pact-webhook",
event_types: ["contact.created", "deal.*"],
}),
});
const sub = await res.json(); // { ..., secret } — save the secret once
import os, requests
res = requests.post(
"https://app.pact.place/v1/webhooks/subscriptions",
json={
"name": "CRM sync",
"url": "https://api.example.com/pact-webhook",
"event_types": ["contact.created", "deal.*"],
},
headers={"Authorization": f"Bearer {os.environ['PACT_API_KEY']}"},
timeout=10,
)
sub = res.json() # save sub["secret"] — shown once
The full set
Snippets for ~30 of the most-used endpoints — accounts, contacts, deals, search, sequences, and the full webhook surface — are generated into the docs from api/openapi.json. For any endpoint not shown here, open the API reference: every operation lists its parameters, request body, and response schema, and you can try calls in the browser.
Generate your own
The snippets come from scripts/gen_sdk_examples.py, which walks the OpenAPI spec. If you fork
Pact or run a self-hosted instance, re-run it against your spec to regenerate examples for your
endpoints.