API quickstart
Base URL: https://api.wisepirit.io. Requests and responses are JSON. Errors look like {"error": {"code", "message"}}.
Start in the sandbox (free)
A sandbox lets you build and test everything before you have a plan or a phone number. In the dashboard, type your app name and choose Create sandbox (free test). Sandbox keys start with wp_test_. Sessions, the widget, in-app chat, the team inbox, consent, STOP, START and HELP, and webhooks all work exactly as they do live. The difference is that texts go to a pretend number, +15550109999, and never reach a real phone. Nothing is charged, and webhook events carry "livemode": false.
To pretend a customer texted you, use Simulate a customer text in the dashboard, or call:
POST /v1/sandbox/inbound
Authorization: Bearer wp_test_...
{ "from": "+15555550123", "body": "Count me in for Sunday" }
When you're ready, create a live account, choose a plan or redeem a comp code, and swap your wp_test_ key for a wp_live_ key. No other code changes.
1. Get an API key
Sign in to the dashboard, create an account for your site or app, choose a plan or redeem a comp code, and create a key. Keys start with wp_live_ and belong on your server only.
2. Open a session for the signed-in person
POST /v1/sessions
Authorization: Bearer wp_live_...
{ "user": { "id": "u_123", "name": "Jordan Lee", "role": "staff" } }
Roles: staff see the text inbox and their chats; member sees only their chats. The reply has a token for the browser, good for 8 hours.
3. Add the widget
<script src="https://api.wisepirit.io/v1/widget.js"
data-session-url="/api/wisepirit/session" async></script>
data-session-url is a route on your site that returns the session from step 2. If your sign-in lives in the browser (for example Supabase or Firebase), define window.WisePIRITSession = async () => ({ token, expires_at, user }) before the script loads and the widget will call it instead. From your page you can call WisePIRIT.open() and WisePIRIT.chatWith(["u_456"]).
4. Send a text
POST /v1/messages
Authorization: Bearer wp_live_...
{ "to": "+15555550123", "body": "Your appointment is tomorrow at 3.",
"consent": { "source": "Checked 'Text me' at signup" } }
You can text someone only if they agreed (send consent once) or they texted you first. People who reply STOP can't be texted until they reply START.
Endpoints
POST /v1/sessions | Session token for one person |
POST /v1/messages | Send a text |
POST /v1/contacts · GET /v1/contacts | Contacts and consent |
GET /v1/threads | Conversations (texts and chats) |
GET|POST /v1/threads/{id}/messages | Read or post in a conversation |
POST /v1/chats | Start a chat between users |
POST /v1/webhooks | Get signed events on your server |
GET /v1/account | Plan, number and usage |
Webhooks
Events: message.received, message.status, contact.opted_out. Each delivery carries WisePIRIT-Signature: t=<unix>,v1=<hex>, where v1 is HMAC-SHA256 of "<t>.<raw body>" with your webhook secret. Reject deliveries older than five minutes.