WisePIRIT

API quickstart

Base URL: https://api.wisepirit.io. Requests and responses are JSON. Errors look like {"error": {"code", "message"}}.

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. 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/sessionsSession token for one person
POST /v1/messagesSend a text
POST /v1/contacts ยท GET /v1/contactsContacts and consent
GET /v1/threadsConversations (texts and chats)
GET|POST /v1/threads/{id}/messagesRead or post in a conversation
POST /v1/chatsStart a chat between users
POST /v1/webhooksGet signed events on your server
GET /v1/accountPlan, 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.