Quickstart
From an API key to your first answer in five minutes.
1. Get an API key
Sign up in the console, open API keys and create a key. You get two values:
- a key ID like
7Hx2Qp9LmZ, which identifies the key; - a signing secret like
your_secret, shown only once. Keep it on your server.
export SIGWISE_API_KEY=your_key_id
export SIGWISE_SECRET=your_secretEvery account starts with free credit and three signals (is_scammer, trust_score and buyer_intent), so you can send events right away.
2. Set up a client
Requests are authenticated with a short-lived token signed with your secret (see Authentication). The SDKs sign each request for you. With plain HTTP, a small shell function does it:
# Signs a JWT with $SIGWISE_SECRET that is valid for five minutes.
b64url() { openssl base64 -A | tr '+/' '-_' | tr -d '='; }
sign() {
local now=$(date +%s) h p
h=$(printf '{"alg":"HS256","typ":"JWT"}' | b64url)
p=$(printf '{"iat":%d,"exp":%d}' "$now" "$((now + 300))" | b64url)
printf '%s.%s.%s' "$h" "$p" \
"$(printf '%s.%s' "$h" "$p" | openssl dgst -sha256 -hmac "$SIGWISE_SECRET" -binary | b64url)"
}
API=https://api.sigwise.aiimport { SigWise } from "@sigwise/node";
// Reads SIGWISE_API_KEY and SIGWISE_SECRET.
const sigwise = new SigWise();from sigwise import SigWise
# Reads SIGWISE_API_KEY and SIGWISE_SECRET.
sigwise = SigWise()import sigwise "github.com/thesigwise/sigwise-go"
// Empty values fall back to SIGWISE_API_KEY and SIGWISE_SECRET.
client := sigwise.New("", "")// Null arguments fall back to SIGWISE_API_KEY and SIGWISE_SECRET.
$sigwise = new SigWise\Client();require "sigwise"
# Nil arguments fall back to SIGWISE_API_KEY and SIGWISE_SECRET.
sigwise = SigWise::Client.newSDKs
See SDKs for how to install each one. The cURL tab works from any HTTP client, no SDK needed.
3. Send events
Send what happens to an object. Here, a message from user-42:
curl -X POST "$API/v1/objects/user-42/events?api_key=$SIGWISE_API_KEY" \
-H "Authorization: Bearer $(sign)" -H 'Content-Type: application/json' \
-d '{"object_type":"user","events":[
{"type":"event","name":"profile.updated","metadata":{"field":"bio"}},
{"type":"message","content":"is this still available? can I pay by wire?"}
]}'await sigwise.events.ingest("user-42", {
object_type: "user",
events: [
{ type: "event", name: "profile.updated", metadata: { field: "bio" } },
{ type: "message", content: "is this still available? can I pay by wire?" },
],
});sigwise.events.ingest(
"user-42",
object_type="user",
events=[
{"type": "event", "name": "profile.updated", "metadata": {"field": "bio"}},
{"type": "message", "content": "is this still available? can I pay by wire?"},
],
)_, err := client.Events.Ingest(ctx, "user-42", &sigwise.IngestRequest{
ObjectType: sigwise.String("user"),
Events: []sigwise.EventInput{
{Type: sigwise.EventTypeEvent, Name: sigwise.String("profile.updated"), Metadata: sigwise.Metadata{"field": "bio"}},
{Type: sigwise.EventTypeMessage, Content: sigwise.String("is this still available? can I pay by wire?")},
},
})$sigwise->events->ingest('user-42', [
'object_type' => 'user',
'events' => [
['type' => 'event', 'name' => 'profile.updated', 'metadata' => ['field' => 'bio']],
['type' => 'message', 'content' => 'is this still available? can I pay by wire?'],
],
]);sigwise.events.ingest("user-42", {
object_type: "user",
events: [
{ type: "event", name: "profile.updated", metadata: { field: "bio" } },
{ type: "message", content: "is this still available? can I pay by wire?" },
],
})The API answers 202 Accepted and schedules an analysis a few seconds later:
{ "object_id": "user-42", "accepted": 2, "analysis_status": "scheduled", "analysis_delay_ms": 5000 }4. Read the answers
curl "$API/v1/objects/user-42?api_key=$SIGWISE_API_KEY" -H "Authorization: Bearer $(sign)"const object = await sigwise.objects.get("user-42");
console.log(object.analysis, object.pending);obj = sigwise.objects.get("user-42")
print(obj["analysis"], obj["pending"])obj, err := client.Objects.Get(ctx, "user-42")$object = $sigwise->objects->get('user-42');object = sigwise.objects.get("user-42")
p object["analysis"], object["pending"]analysis holds the latest answer for each signal; pending lists the signals that have no answer yet. Right after ingesting, everything is pending until the analysis runs.
5. Ask your own question
Add a signal with PUT /v1/signals/{key}. It is used from the next analysis on:
curl -X PUT "$API/v1/signals/wants_refund?api_key=$SIGWISE_API_KEY" \
-H "Authorization: Bearer $(sign)" -H 'Content-Type: application/json' \
-d '{"type":"noul","instructions":"Is this customer asking for a refund?",
"criteria":{"true":"asks for money back","false":"anything else"}}'await sigwise.signals.upsert("wants_refund", {
type: "noul",
instructions: "Is this customer asking for a refund?",
criteria: { true: "asks for money back", false: "anything else" },
});sigwise.signals.upsert(
"wants_refund",
type="noul",
instructions="Is this customer asking for a refund?",
criteria={"true": "asks for money back", "false": "anything else"},
)_, err := client.Signals.Upsert(ctx, "wants_refund", &sigwise.SignalInput{
Type: sigwise.SignalTypeNoul,
Instructions: "Is this customer asking for a refund?",
Criteria: map[string]string{"true": "asks for money back", "false": "anything else"},
})$sigwise->signals->upsert('wants_refund', [
'type' => 'noul',
'instructions' => 'Is this customer asking for a refund?',
'criteria' => ['true' => 'asks for money back', 'false' => 'anything else'],
]);sigwise.signals.upsert("wants_refund", {
type: "noul",
instructions: "Is this customer asking for a refund?",
criteria: { true: "asks for money back", false: "anything else" },
})Existing objects are not re-analyzed automatically, since each analysis is billed. To answer the new signal for them, start a backfill.
Next
- Signals: the three types and how to write criteria.
- Direct moderation: score content before publishing it.
- Webhooks: stop polling and get answers pushed to you.