Free setup on annual plans

Sign up today!

Best Practices

Best Practices

API Reference: Best Practices

These recommendations follow from how the AnswerPal API actually behaves: how tokens expire, how access follows roles, which calls are safe to repeat and which errors you can retry. Use them as a checklist when you build or review an integration.

Diagram showing API client following best practices: secure authentication, retry logic, pagination, error handling, and compliance.

Sign-in and tokens

  • One account per integration
    Create a separate representative account for each integration. Changes can then be traced to it, and you can deactivate it without locking out a person.
  • Reuse the token
    Sign in once and reuse the JWT for every call. Signing in per call is slow and adds nothing.
  • Expect expiry
    A token is valid for 12 hours and cannot be refreshed. Sign in again shortly before that, or when a call answers 401 Unauthorized, and repeat that call once.
  • Keep secrets secret
    Store the password in a secret store, never in source code. Never log the Authorization header or put a token in a URL.
Gebruik HTTPS

Use HTTPS

Always use HTTPS for all API requests.

Custom Identifiers

Secure Credentials

Keep passwords and tokens out of source code, logs and URLs.

Rotate Regularly

Plan for Expiry

Tokens expire after 12 hours. Sign in again; there is no refresh endpoint.

Beperk rechten

Least-Privilege Role

Access follows the role of the account. Give the integration account the lowest role it needs.

Roles and access

There are no scoped API tokens: a token can do exactly what the role of its account allows, for the one customer in the token. Choose the lowest role that covers the endpoints you call; each endpoint page shows the allowed roles. Endpoints of subscription features, such as mailings, also answer 403 Forbidden when the customer’s subscription does not include the feature.

Reading lists

  • Paging
    Paged lists take pageNumber (starting at 1) and pageSize. Some cap the page size (for example 100 for hook actions and topic channels, 200 for mailing lists), others take the value you send. Ask for moderate pages, such as 50 or 100, and follow the totals in the answer.
  • Sorting
    Where a list takes sortBy and sortOrder, an unknown sortBy gives 400 Bad Request with the code InvalidSortProperty.
  • Filters
    Filter on the server with the query parameters an endpoint offers, instead of fetching everything and filtering yourself.

Retries and duplicates

  • Creates are not idempotent
    Most POST endpoints have no idempotency key. If a create times out, read the list first to see whether it was created before you send it again.
  • Idempotency keys for knowledge bases
    The knowledge-base write endpoints take an Idempotency-Key header; file uploads and replacements require it. Reusing a key for a different request gives 409 Conflict with the code idempotency_key_conflict.
  • Outgoing messages
    When sending an SMS or WhatsApp message answers 502 Bad Gateway with a code ending in SendUncertain, the provider may have sent it. Do not resend blindly; check the ticket first.
  • Reads
    GET calls change nothing and are safe to repeat.

Handling errors

  • 400 Bad Request
    Fix the request; repeating it unchanged gives the same answer. Error bodies differ per endpoint, so read the status code first and the body second.
  • 401 and 403
    401: sign in again. 403: the role or the subscription does not allow the call; retrying does not help.
  • 409 Conflict
    Read the code when there is one. Some conflicts are permanent until something changes, such as StorageLimitExceeded or UserLimitExceeded; others, such as a record changed by someone else, need a fresh read first.
  • 429 Too Many Requests
    Wait the number of seconds in the Retry-After header before you try again.
  • 5xx
    Retry 502, 503 and 504 a few times with growing pauses. For a 500, keep the traceId from the body and mention it when you contact support.

Error Codes describes every error shape; Rate Limits lists where 429 and 413 can occur.

Links with a token are secrets

Some links work without signing in because the token in the link is the credential, for example file and photo links (/api/File/{accessToken}, /api/PlaceDescriptionPhotos/{accessToken}), unsubscribe links and the feedback and escalation links in replies. Anyone who has such a link can use it. Do not log these URLs, do not post them in shared places, and pass them on only to the person they are meant for.

Credentials AnswerPal stores for you

Settings on the customer, on actions, documents and channels can hold credentials that AnswerPal uses to call other systems: the API password for your own systems, mailbox passwords, a Microsoft Graph client secret or an OpenAI key. They are only used by AnswerPal for those outgoing calls.

  • A representative token never gets a stored secret back; a read only shows whether one is set (fields starting with has). Only the phone runtime, with a phone token, can read the keys it needs for a call.
  • Leaving the field empty on an update keeps the stored value; to remove it, set the matching clear... flag.
  • Give AnswerPal its own account on your side, with only the rights its actions and documents need, and rotate that password there.

Compatibility

There is one version of the API and no version number in the URL. Write tolerant clients: ignore response properties you do not know, do not depend on the order of properties, and send only the fields an endpoint documents.

FAQ

There is no separate sandbox API; every call works on real data of the customer in the token. Test with test data and with channels and addresses that do not reach real people.

No. Access follows the role of the account. Create an account with the lowest role that works for your integration.

Signed-in calls have no request-per-minute limit, but do not poll in tight loops. Rate Limits lists the limits that do exist.

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