Skip to content

Getting Started

This is the one quickstart. It takes you from nothing to a visible reply from an AI employee that you built: sign in, create an agent, give it a small workflow, make an API key, then start a conversation and read the answer. Plan on about fifteen minutes, plus the wait for a test login if you do not have one yet.

Everything, building an agent and running a session with one, goes through a single GraphQL API.

StepWhat you doCredential it usesTime
1Get a test loginnoneup to 1 day
2Sign inemail and password1 minute
3Create the agentdashboard token2 minutes
4Build, publish and attach a workflowdashboard token4 minutes
5Make an API keydashboard token1 minute
6Start a session, send a message, read the replyAPI key, session token5 minutes

Before you start: three rules every request follows

Section titled “Before you start: three rules every request follows”
  • One URL, POST only. Every call is an HTTP POST to the GraphQL URL with a JSON body { "query": "...", "variables": { ... } }. Send inputs as variables, as the samples below do.
  • The platform header. Every request carries x-huat-platform: customer. Without it even a valid credential answers Platform is not specified!. See the header every request needs.
  • Check errors before data. Errors come back in a JSON errors array with a machine-readable extensions.code, usually with HTTP status 200. See Errors.

Request bodies must not be compressed: a Content-Encoding other than identity is refused with HTTP 415. Most clients never send one. Details: Compressed request bodies: HTTP 415.

There is no self-serve sign-up. A new developer gets a test workspace by asking for one:

  1. Open the contact page and fill in the form: your name and work email.
  2. In the message, write “developer test workspace” and say what you want to build in a sentence or two.
  3. You receive a login for the test environment within one working day.

The login belongs to the workspace owner, which is what you need: building agents and connecting channels are owner operations. If you already have a login, skip to step 2.

mutation Login($input: SignInInput!) {
login(input: $input) {
accessToken
refreshToken
}
}
{
"input": {
"email": "you@example.com",
"password": "<YOUR_PASSWORD>"
}
}

Headers: x-huat-platform: customer.

Expected response (the token is shortened here):

{
"data": {
"login": {
"accessToken": "eyJhbGciOi...",
"refreshToken": "eyJhbGciOi..."
}
}
}

The accessToken is your dashboard token. Send it as Authorization: Bearer <accessToken> on steps 3 to 5, together with x-huat-platform: customer. Treat it like a password.

The three credentials (dashboard token, API key, session token) and when each applies are explained once, on Authentication.

An agent is the persona a session talks to. It has no workflow yet, which step 4 adds.

mutation CreateAgent($input: CreateAgentInput!) {
createAgent(input: $input) {
id
name
status
workflowId
}
}
{
"input": {
"name": "Helpdesk triage",
"position": "IT helpdesk assistant",
"personaPrompt": "You are a calm, precise IT helpdesk assistant. Ask one question at a time and never promise a fix you cannot make.",
"openingGreeting": "Hi, I can log an IT ticket for you. What is the problem?",
"useCase": "SUPPORT",
"voiceTier": "STANDARD",
"avatarBackend": "CLIENT_3D"
}
}

Expected response: status is ACTIVE and workflowId is null. Write down the agent id; the rest of this page calls it <AGENT_ID>.

A workflow is the graph of steps the agent runs on every turn. This one has three: it starts, asks the model to pick a queue, and replies. An agent with no published workflow cannot answer, so this step matters.

4a. Create the empty workflow.

mutation CreateWorkflow($input: CreateWorkflowInput!) {
createWorkflow(input: $input) {
id
name
isPublished
}
}
{
"input": {
"name": "Ticket routing",
"description": "Classifies a ticket as L1, L2 or L3 and tells the user where it goes."
}
}

Write down the workflow id (<WORKFLOW_ID>).

4b. Save the graph. nodes and edges are JSON, so they must travel as variables, never inline in the query.

mutation SaveGraph($input: UpdateWorkflowInput!) {
updateWorkflow(input: $input) {
id
version
isPublished
}
}
{
"input": {
"id": 12,
"nodes": [
{
"id": "start",
"type": "start",
"label": "Start",
"config": {},
"position": { "x": 0, "y": 0 }
},
{
"id": "classify",
"type": "llm",
"label": "Classify level",
"config": {
"promptTemplate": "You route IT support tickets. Read the ticket and answer with one word: L1 for password resets, account unlocks and how-to questions; L2 for a broken device, application or connection that needs a technician; L3 for an outage, a security incident or anything affecting many people.\n\nTicket: \"{{userMessage}}\"",
"outputVar": "level",
"matchAnyOf": ["L1", "L2", "L3"],
"streamOutput": false
},
"position": { "x": 0, "y": 100 }
},
{
"id": "reply",
"type": "response",
"label": "Tell the user",
"config": {
"messageTemplate": "Thanks. Your ticket goes to the {{level}} queue; we will reply here."
},
"position": { "x": 0, "y": 200 }
}
],
"edges": [
{ "id": "e1", "source": "start", "target": "classify" },
{ "id": "e2", "source": "classify", "target": "reply" }
]
}
}

Replace 12 with your <WORKFLOW_ID>. Node type values are lowercase. Expected response: isPublished is false; this saved a draft.

4c. Publish it.

mutation Publish($id: Int!) {
publishWorkflow(id: $id) {
id
version
isPublished
}
}
{ "id": 12 }

Expected response: isPublished is true. If the graph is not runnable (no start node, an unreachable node) the call refuses with a message naming the problem.

4d. Attach it to the agent. id is a separate argument here, not a field of input.

mutation Attach($id: ID!, $input: UpdateAgentInput!) {
updateAgent(id: $id, input: $input) {
id
workflowId
status
}
}
{ "id": "7", "input": { "workflowId": 12 } }

Use your <AGENT_ID> and <WORKFLOW_ID>. Expected response: workflowId now holds your workflow’s id. The agent is ready.

Your server talks to Wetel with an API key, not with the dashboard token. Create one named key per consumer so you can revoke one without breaking the others.

mutation CreateKey($name: String!) {
createNamedApiKey(name: $name) {
id
name
key
warning
}
}
{ "name": "quickstart-test" }

Expected response: key is a string starting sk_. It is shown once. Copy it into your server’s secret store now; Wetel keeps only a hash and cannot show it again. Keep the id in case you need to revoke it with revokeNamedApiKey.

Now act as your application. These three calls use the API key and a session token, never the dashboard token.

6a. Start a session. Header: X-Api-Key: <YOUR_API_KEY> and x-huat-platform: customer.

mutation StartSession($input: SdkStartInput!) {
sdkStart(input: $input) {
sessionId
avatarToken
agentId
graphqlEndpoint
}
}
{ "input": { "agentId": 7, "clientId": "quickstart-001" } }

Expected response: a sessionId, an avatarToken (the short-lived session token, about an hour) and the graphqlEndpoint. clientId is your own id for this conversation; step 6c uses it to find the session again.

6b. Send a message. Header: Authorization: Bearer <avatarToken> and x-huat-platform: customer.

mutation SendMessage($input: SdkSendMessageInput!) {
sdkSendMessage(input: $input)
}
{
"input": {
"sessionId": 42,
"text": "My laptop cannot connect to the office VPN since this morning."
}
}

Expected response: { "data": { "sdkSendMessage": true } }. That true only acknowledges the message. The reply is produced asynchronously, a few seconds later.

6c. Read the reply. Wait about three seconds, then ask for the session’s messages. Header: X-Api-Key: <YOUR_API_KEY>.

query ReadReply($externalCustomerId: String!, $first: Int) {
sessionsByExternalCustomerId(
externalCustomerId: $externalCustomerId
first: $first
) {
edges {
node {
id
status
messages {
role
text
}
}
}
}
}
{ "externalCustomerId": "quickstart-001", "first": 1 }

Expected response: the messages in order. Your message has role USER; the agent’s answer is the MODEL message after it:

{
"data": {
"sessionsByExternalCustomerId": {
"edges": [
{
"node": {
"id": 42,
"status": "ACTIVE",
"messages": [
{
"role": "USER",
"text": "My laptop cannot connect to the office VPN since this morning."
},
{
"role": "MODEL",
"text": "Thanks. Your ticket goes to the L2 queue; we will reply here."
}
]
}
}
]
}
}
}

If the MODEL message is not there yet, wait two seconds and repeat 6c. That reply is your agent answering. The queue (L2) is chosen by the model, so yours may say L1 or L2.

Steps 6a to 6c, plus ending the session, are also a complete program that starts a session, sends the message, polls for the reply every two seconds for up to sixty, prints it and ends the session. Pick your language. Set WETEL_API_KEY and WETEL_AGENT_ID and run it; the comment at the top of each file has the exact command. The same files are on Downloads.

hello-ticket.sh
#!/usr/bin/env bash
# Hello ticket: start a session, send one message, poll for the reply, end the session.
# Needs curl and jq. Run: WETEL_API_KEY=sk_... WETEL_AGENT_ID=7 bash hello-ticket.sh
set -euo pipefail
API_URL="${WETEL_API_URL:-https://api.wetel.dev/graphql}"
AGENT_ID="${WETEL_AGENT_ID:-1}"
CLIENT_ID="ticket-$(date +%s)" # one clientId per conversation
TEXT="My laptop cannot connect to the office VPN since this morning."
read -r -d '' START <<'GRAPHQL' || true
mutation StartSession($input: SdkStartInput!) {
sdkStart(input: $input) {
sessionId
avatarToken
agentId
graphqlEndpoint
}
}
GRAPHQL
read -r -d '' SEND <<'GRAPHQL' || true
mutation SendMessage($input: SdkSendMessageInput!) {
sdkSendMessage(input: $input)
}
GRAPHQL
read -r -d '' POLL <<'GRAPHQL' || true
query PollSession($externalCustomerId: String!, $first: Int) {
sessionsByExternalCustomerId(externalCustomerId: $externalCustomerId, first: $first) {
totalCount
edges {
node {
id
status
messages {
id
role
text
turnIndex
createdAt
}
}
}
}
}
GRAPHQL
read -r -d '' END <<'GRAPHQL' || true
mutation EndSession($input: SdkEndSessionInput!) {
sdkEndSession(input: $input) {
sessionId
durationSeconds
evaluation {
score
summary
}
}
}
GRAPHQL
# gql QUERY VARIABLES_JSON AUTH_HEADER: prints .data, or the first error and exits.
gql() {
local response
response=$(jq -n --arg query "$1" --argjson variables "$2" '{query: $query, variables: $variables}' |
curl -sS "$API_URL" -H "Content-Type: application/json" -H "x-huat-platform: customer" -H "$3" --data-binary @-)
if [ "$(jq '.errors | length' <<<"$response")" != "0" ]; then
jq -r '.errors[0] | "\(.extensions.code): \(.message)"' <<<"$response" >&2
exit 1
fi
jq '.data' <<<"$response"
}
# 1. Start a session with the API key.
STARTED=$(gql "$START" "$(jq -n --argjson agentId "$AGENT_ID" --arg clientId "$CLIENT_ID" '{input: {agentId: $agentId, clientId: $clientId}}')" "X-Api-Key: $WETEL_API_KEY")
SESSION_ID=$(jq '.sdkStart.sessionId' <<<"$STARTED")
AVATAR_TOKEN=$(jq -r '.sdkStart.avatarToken' <<<"$STARTED")
# 2. Send the message with the session token. It returns true at once.
gql "$SEND" "$(jq -n --argjson sessionId "$SESSION_ID" --arg text "$TEXT" '{input: {sessionId: $sessionId, text: $text}}')" "Authorization: Bearer $AVATAR_TOKEN" >/dev/null
# 3. Poll the session's messages until the reply arrives
# (the reply is every MODEL message after the last USER message).
REPLY=""
DEADLINE=$(($(date +%s) + 60))
while [ -z "$REPLY" ] && [ "$(date +%s)" -lt "$DEADLINE" ]; do
sleep 2
POLLED=$(gql "$POLL" "$(jq -n --arg clientId "$CLIENT_ID" '{externalCustomerId: $clientId, first: 1}')" "X-Api-Key: $WETEL_API_KEY")
REPLY=$(jq -r --argjson id "$SESSION_ID" '
.sessionsByExternalCustomerId.edges[].node | select(.id == $id) | .messages
| ((map(.role) | rindex("USER")) // -1) as $u
| .[($u + 1):] | map(select(.role == "MODEL") | .text) | join("\n")' <<<"$POLLED")
done
echo "${REPLY:-No reply within the timeout.}"
# 4. End the session with the session token.
gql "$END" "$(jq -n --argjson sessionId "$SESSION_ID" '{input: {sessionId: $sessionId}}')" "Authorization: Bearer $AVATAR_TOKEN" >/dev/null

In short: your app logs in and builds the agent and workflow, starts a session with the API key, sends a message with the session token, and later reads the agent’s reply from the session’s messages.

sequenceDiagram
participant You as Your app
participant API as Wetel API
participant Agent as Agent and workflow
You->>API: login, createAgent, workflow calls, createNamedApiKey (dashboard token)
You->>API: sdkStart (API key)
API-->>You: sessionId and session token
You->>API: sdkSendMessage (session token)
API->>Agent: run the published workflow
Agent-->>API: the reply, a few seconds later
You->>API: read the session's messages (API key)
API-->>You: your message and the agent's reply

You built an agent once (steps 2 to 5) and then ran it the way a product would (step 6): a long-lived key on your server starts sessions, a short-lived token is the only thing a browser needs, and the reply arrives separately from the message that caused it.

What you seeCauseFix
Platform is not specified! with a valid credentialThe x-huat-platform: customer header is missingAdd the header to every request
Invalid username / password!Wrong email or password; every sign-in failure reads the sameCheck both; after repeated failures the account locks for a while
TWO_FACTOR_REQUIRED after a correct passwordThe account has two-factor sign-in onUse signIn and completeSignInWithTwoFactor instead of login; see Authentication
UNAUTHENTICATED / UnauthorizedThe wrong credential for the call (API key on a dashboard call, or the reverse), or an expired tokenSteps 3 to 5 take the dashboard token; step 6a and 6c the API key; step 6b the session token
An API key is rejectedThe key is from another environment, or was revokedMint the key on the same environment you call
Cannot query field ... or BAD_USER_INPUT on a nodeA typo, a capitalised node type, or nodes sent inline instead of as variablesCopy the variables exactly; type values are lowercase
publishWorkflow refuses the graphNo start node, or a node nothing connects toFix what the message names; workflow diagnostics lists findings before you publish
sdkStart returns NOT_FOUND for the agentThe agent id is not in the workspace of the API keyUse the id from step 3, and a key from the same workspace
The message was accepted but no MODEL message ever showsThe agent has no published workflow attached, or the run failedConfirm step 4d (workflowId is set); open the run in Observability
The reply is a generic apologyThe workflow failed on that turnRead the run’s node trace in Observability
HTTP 415Your HTTP client compresses request bodiesTurn request compression off for calls to Wetel
Too many requestsA per-address limit on sign-in or on session startsWait a minute and retry; see Rate limiting

More symptoms and their causes: Troubleshooting.