Free setup on annual plans

Sign up today!

API Reference: Auth endpoints

The Auth endpoints sign in representatives and phone channels and return a JWT, and they handle password resets. None of them needs an existing token. Send the returned token as Authorization: Bearer {token} on every other AnswerPal API call.

Endpoints

  • POST /api/Auth/login
    Access: Public (no bearer token)
    Sign in a representative with username, password and hostname. Returns { "token": "..." }.
  • POST /api/Auth/phone-login
    Access: Public (no bearer token)
    Sign in a phone channel with its phoneNumber and the Twilio accountSid of the customer. Returns a phone token and the channel’s default language.
  • POST /api/Auth/request-password-reset
    Access: Public (no bearer token)
    Ask for a password reset link by email and hostname. Always answers 200 OK when both fields are filled in.
  • POST /api/Auth/reset-password
    Access: Public (no bearer token)
    Set a new password with the reset token from the e-mail and a newPassword. Answers 204 No Content.

Sign in

Representative login

Request body

  • username (string, required)
    The representative’s username. Only active representatives that are not deleted can sign in.
  • password (string, required)
    The representative’s password.
  • hostname (string, required)
    The host name of the customer’s AnswerPal portal, for example app.answerpal.eu. The representative must belong to the customer with that host name.

Response

  • token (string)
    A JWT that is valid for 12 hours.
POST /api/Auth/login
Content-Type: application/json

{
  "username": "agent@example.com",
  "password": "correct horse battery staple",
  "hostname": "app.answerpal.eu"
}
200 OK
Content-Type: application/json

{
  "token": "eyJhbGciOi..."
}

Phone login

Used by the phone runtime of a phone channel. The phone number must belong to a phone channel that is not deleted, of the customer whose Twilio account has this Account SID.

Request body

  • phoneNumber (string, required)
    The phone number of the channel, exactly as configured on the channel.
  • accountSid (string, required)
    The Twilio Account SID of the customer.

Response

  • token (string)
    A phone token, valid for 12 hours. It is accepted only by the endpoints whose access says “phone token” and only for its own channel.
  • phoneDefaultLanguage (string or null)
    The starting language configured on the phone channel, as a 3-letter ISO 639-2 code such as nld. null when the channel has none; the language then follows the called number.
POST /api/Auth/phone-login
Content-Type: application/json

{
  "phoneNumber": "+3225550100",
  "accountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
200 OK
Content-Type: application/json

{
  "token": "eyJhbGciOi...",
  "phoneDefaultLanguage": "nld"
}

Password reset

A password reset takes two calls. The first sends an e-mail with a reset link to the representative; the link holds a one-time token. The second sets the new password with that token.

Request reset: body

  • email (string, required)
    The representative’s e-mail address.
  • hostname (string, required)
    The host name of the customer’s portal. It selects the customer; the link in the e-mail always points to the customer’s own portal.

The answer is 200 OK whether or not a representative matches, so the call does not reveal which addresses have an account. The token is valid for 4 hours and can be used once.

Reset password: body

  • token (GUID, required)
    The token from the reset link.
  • newPassword (string, required)
    At least 8 characters, with at least 3 of these 4: a digit, a lowercase letter, an uppercase letter, a symbol.

On success the answer is 204 No Content and the token is removed. A password that does not meet the rule, or a token that is unknown, used or expired, gives 400 Bad Request.

POST /api/Auth/request-password-reset
Content-Type: application/json

{
  "email": "agent@example.com",
  "hostname": "app.answerpal.eu"
}
POST /api/Auth/reset-password
Content-Type: application/json

{
  "token": "00000000-0000-0000-0000-000000000000",
  "newPassword": "N3w-password!"
}

Tokens

Tokens are signed JWTs. Every call checks the issuer, the audience, the lifetime and the signature. Send the token in the Authorization header; the real-time hubs (/chatHub, /ticketHub) also accept it as the access_token query parameter.

Representative token claims

  • sub
    The representative’s username.
  • CustomerID, CustomerRepID
    The customer and the representative. Every call is limited to the data of this customer.
  • TimeZone, Locale, Country
    The representative’s preferences; UTC, en-US and US when not set.
  • role, Role
    The user role, by name and as a number (see the Representatives page).
  • jti
    A unique ID per token.

Phone token claims

  • sub
    Always PhoneAuth.
  • CustomerID, ChannelID, PhoneNumber
    The customer, the phone channel and its number. The token works only for that channel.
  • jti
    A unique ID per token.

Status codes

  • 200 OK
    Login and phone login succeeded, or a reset request was accepted.
  • 204 No Content
    The password was reset.
  • 400 Bad Request
    A required field is missing, the new password does not meet the rule, or the reset token is invalid or expired.
  • 401 Unauthorized
    Wrong username, password or host name, or no phone channel matches the phone number and Account SID.

FAQ

No. They issue or recover credentials, so they work without a token. Every other endpoint needs the token they return.

12 hours, for representative tokens and phone tokens alike. Sign in again to get a new one.

At least 8 characters, with at least 3 of these 4: a digit, a lowercase letter, an uppercase letter, a symbol.

So that the answer does not reveal whether an e-mail address has an account. When a representative matches, the e-mail with the reset link is sent.

Need more help?

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu

AnswerPal
Bisschoppenhoflaan 380
2100 Antwerp
Belgium

+32.36416685

BE 0862.692.858