Included in Plus

REST API

A survey API for your own code.

50 operations over JSON for surveys, questions, responses, customers, analytics, reports, email sends and webhooks. One base URL, a key in one header, and errors with a code you can branch on.

Read the docs
Within v1, fields and values are only ever added, so code that ignores what it does not know keeps working.
50operations
7scopes for a key
120requests a minute, per key

What is the UserLoop survey API?

The UserLoop API is a REST API at https://app.userloop.io/api/v1. Your server sends an API key as a bearer token and gets JSON back. It creates and publishes surveys, lists responses with the customer and order behind each one, returns NPS and satisfaction scores, sends survey emails from your own events and records answers collected elsewhere. It is part of the Plus plan.

Base URL
https://app.userloop.io/api/v1
Auth
Authorization: Bearer ulk_live_...
Spec
OpenAPI 3.1 at /openapi.json, readable with no key
Plan
Plus, $99 a month, with a 14-day trial

How it works

From no key to a first response in three steps

  1. 01

    Create a key

    In Settings, open API keys and select Create key. Name it, tick what it may do and choose when it expires. UserLoop shows the key once and stores only a hash of it.

  2. 02

    Check it with GET /me

    GET /me needs no scope and answers on every plan. It returns the key's scopes, its organization and the person it acts as, so it is the right first call.

  3. 03

    Read or write

    List surveys, page through responses, read a score or send a survey email. Every endpoint is in the OpenAPI document with the scope it needs.

Resources

Ten groups of endpoints

The 50 operations are grouped by what they work on. Each one names the scope it needs.

  • Surveys

    List, create and update surveys. Publish, unpublish, archive and restore. Get a personal link for one recipient.

  • Questions

    Add, update, move, archive and restore the questions of a survey.

  • Responses

    Search submissions with the dashboard's filters, open one, record a new one and list written answers.

  • Customers

    One item per person across every survey, and a profile with their orders and answer history.

  • Analytics

    Answer counts, NPS and satisfaction scores, responses over time and a survey's results question by question.

  • Reports

    Request a CSV export or a PDF report, list them and download the file when it is ready.

  • Sends

    Email a live survey to one person, report an order or custom event, read a send's status, cancel pending sends.

  • Webhooks

    Add, list, test and remove endpoints, roll a signing secret and fetch sample events.

  • Sites

    List the websites of the organization and get the install snippet for one.

  • Account

    The key itself, the organization, its plan and its usage, plus the OpenAPI document.

Four calls

The requests most integrations start with

Each sample runs as written once you set USERLOOP_API_KEY and replace the ids. The JavaScript needs Node 18 or later and no packages.

GET /responses

List responses, with the order behind each

One item per submission: a customer's answers to one survey in one sitting, newest first, with the customer, the order and the visit's UTM values attached.

  • The dashboard's filters. Date range, survey, channel, answer, score range, written answers only, order value, product, discount code, landing page and UTM values.

  • Cursor pagination. A page holds 1 to 50 submissions, 20 by default. Send next_cursor back as cursor with the same query until has_more is false.

  • Fields are left out, never null. A submission with no order has no order field. New channels, question types and fields can appear within v1, so ignore the ones you do not know.

# The last 30 days of submissions to one survey, newest first
curl -G https://app.userloop.io/api/v1/responses \
  -H "Authorization: Bearer $USERLOOP_API_KEY" \
  --data-urlencode "survey_id=SURVEY_ID" \
  --data-urlencode "range=30d" \
  --data-urlencode "limit=50"
Scope: responses:read. A cursor used with different filters is refused with 400 invalid_cursor.

GET /analytics/scores

Read an NPS or satisfaction score

One call returns the score for a question over a date range, so you do not page through responses and add them up yourself.

  • Three shapes. kind is nps, scale or csat. NPS runs from -100 to 100, with promoters, passives and detractors counted and the 0 to 10 distribution.

  • Revenue beside the score. Each NPS segment carries the revenue and average order value of the orders attached to those answers.

  • Filters apply. Narrow a score by channel, answer, order value, product, discount code or UTM value. To compare two periods, call it once for each range.

# NPS for one question over the last 90 days
curl -G https://app.userloop.io/api/v1/analytics/scores \
  -H "Authorization: Bearer $USERLOOP_API_KEY" \
  --data-urlencode "survey_id=SURVEY_ID" \
  --data-urlencode "question_id=QUESTION_ID" \
  --data-urlencode "range=90d"
Scope: responses:read. The analytics endpoints count whole UTC days.

POST /surveys/{survey_id}/send

Send a survey email from your own event

When a booking ends, a ticket closes or an order is delivered in your system, one request emails a live email survey to that person.

  • One person, now. Give the recipient's email, a first name for the greeting and your own external_id. The same external_id never emails the same survey twice.

  • Or report a moment. POST /sends reports order_placed, order_shipped, order_delivered, checkout_abandoned or a custom event to email surveys that already listen for it through an API trigger, and their saved wait and rules decide.

  • Checks still run. Unsubscribes, suppressions, the limit per customer and the plan's monthly email allowance apply when the email goes. Sending through the API needs approval on the account first.

# Email one live email survey to one person now
curl https://app.userloop.io/api/v1/surveys/SURVEY_ID/send \
  -H "Authorization: Bearer $USERLOOP_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: booking-1042-survey" \
  -d '{
    "email": "emma@example.com",
    "first_name": "Emma",
    "external_id": "booking-1042"
  }'
Scope: surveys:write. queued does not mean delivered: read GET /sends/{send_id} for the outcome.

POST /responses

Record a response collected elsewhere

Answers gathered in your own app, in a support tool or by an agent on a call can be stored as a submission to a live link, email or website survey.

  • Checked before anything is stored. Every answer is checked against the survey's live version. A 400 lists each problem with its field, and nothing is recorded.

  • Try it without writing. validate_only runs every check and answers what would be recorded. Use a new Idempotency-Key when you send it for real.

  • Safe to retry. Send the same external_id and answers again and the submission is not stored twice. A 202 means accepted: it appears within about a minute, under the API channel.

# Record one submission to a live link, email or website survey
curl https://app.userloop.io/api/v1/responses \
  -H "Authorization: Bearer $USERLOOP_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ticket-1042" \
  -d '{
    "survey_id": "SURVEY_ID",
    "external_id": "ticket-1042",
    "answers": [
      { "question_id": "SCORE_QUESTION_PUBLIC_ID", "score": 9 },
      { "question_id": "TEXT_QUESTION_PUBLIC_ID", "text": "Helpful support" }
    ]
  }'
Scope: responses:write. Checkout, store popup and theme block surveys cannot take responses this way.

The rules

What holds for every request

Keys
A key starts ulk_live_ and goes in the Authorization header as a bearer token. A key sent in the address is refused with 400 key_in_query. An organization can have up to 25 active keys, and a revoked key stops working within a minute.
Scopes
7 scopes, chosen when the key is created: surveys:read, surveys:write, responses:read, responses:write, reports:write, account:read and account:write. A missing one answers 403 insufficient_scope and names it in required_scope.
Acting as a person
A key does everything as the person who created it, within their role. Publishing, unpublishing, archiving and restoring a survey need a key made by an organization admin. When that person leaves, their keys stop within 15 minutes.
Expiry
30 days, 90 days, 1 year or never, chosen at creation. An expired key answers 401 key_expired and cannot be renewed, so create its replacement first.
Pagination
Every list returns data, has_more and next_cursor. Treat the cursor as opaque and keep the query the same between pages. Only limit may change.
Rate limit
About 120 requests a minute for each key, stated on every response as RateLimit-Policy. Over it, the API answers 429 with a Retry-After header in seconds. There is no remaining-requests header, so plan to stay under.
Idempotency
Send an Idempotency-Key header on any POST, PATCH or DELETE. A repeat with the same key within 24 hours returns the first result with Idempotent-Replayed: true. The same key on a different request answers 422.
Errors
Every error is an RFC 9457 problem, sent as application/problem+json with type, title, status, detail, instance and code. Branch on code. detail is a sentence for people and can change.
Request ID
Every response carries a UserLoop-Request-Id header, and an error repeats it as instance. Log it with each failed request.
Contact details
Customer email addresses, names and phone numbers come back masked unless the key was created to allow contact details and the request adds include_contact_details=true. Both are needed.
Versioning
Within v1, fields and enum values are only ever added. Write code that ignores the ones it does not know.
OpenAPI
https://app.userloop.io/api/v1/openapi.json is an OpenAPI 3.1 document, readable with no key. Each operation carries its scope as x-userloop-scope.

First call, and when it fails

A first request, then errors and retries you can code against

GET /me tells you what your key can do. After that, a refusal always says why in a stable code, and a write can be sent again without happening twice.

# Which key is this, whose is it and what may it do?
curl -s https://app.userloop.io/api/v1/me \
  -H "Authorization: Bearer $USERLOOP_API_KEY"

# The machine-readable description. No key needed.
curl -s https://app.userloop.io/api/v1/openapi.json
Retry a 429 or a 503 after Retry-After. Retry a 500 on a GET only: a write that got a 500 may have been done in part.

Around the API

What the API pairs with

The API is for reading and writing on your schedule. Two other tools cover the moments it is the wrong fit for.

Analytics

Counts done for you, with revenue attached

Four analytics endpoints count every response in a range and return the numbers, so a dashboard of your own needs one request, not a crawl.

  • A whole survey. GET /surveys/{survey_id}/analytics returns an overview, a trend and one entry per question, each figure beside the same figure for the period before.

  • One question. GET /analytics/answer-counts gives each answer's count, share, revenue and average order value. GET /analytics/scores gives NPS and satisfaction.

  • Over time. GET /analytics/timeseries counts responses per day, week or month, with empty periods filled with 0.

NPS surveys

Webhooks

Do not poll for new responses

Polling spends your rate limit on work a webhook does for free. Add an endpoint with POST /webhooks and UserLoop posts each response to your URL as it arrives.

  • 6 events. A new answer, a completed submission, an updated one, a low score, a survey published and a survey unpublished.

  • Same IDs both ways. The response_id in an event opens the same submission with GET /responses/{response_id}.

  • Catch up through the API. If your receiver was down, read what you missed with GET /responses and a date range.

Webhooks

Agents

A scoped key for an agent that runs on its own

An agent on a schedule or behind a webhook has nobody to sign in for it. Give it a key with only the scopes its job needs.

  • Least access. A weekly summary needs responses:read and nothing else. An agent that records answers needs responses:write.

  • Masked by default. Unless you create the key with contact details, the agent never sees an email address or a full name.

  • Or sign in. An AI app a person uses can connect to the MCP server with OAuth instead, and gets 93 tools with no key.

Agent recipes

Keep building

The other three ways in

Most projects use the API with one of these.

Frequently asked questions

Does UserLoop have a survey API?

Yes. It is a REST API at https://app.userloop.io/api/v1 with 50 operations for surveys, questions, responses, customers, analytics, reports, email sends and webhooks. Requests and responses are JSON, and the OpenAPI 3.1 description is public.

Is there an NPS API?

Yes. GET /analytics/scores returns the NPS for a question over a date range, from -100 to 100, with promoters, passives and detractors, the 0 to 10 distribution and the revenue attached to each segment. The same endpoint returns satisfaction and number scores.

Which plan includes the API?

The Plus plan, at $99 a month or $950 a year, with a 14-day trial. On another plan, keys are kept but every endpoint except GET /me answers 402 plan_required.

How do I authenticate?

Create a key in Settings under API keys and send it as Authorization: Bearer ulk_live_ followed by the rest of the key. The key carries the scopes you ticked and acts as you. There is no OAuth flow for the API and no key in the query string.

What are the API rate limits?

About 120 requests a minute for each API key. Over the limit, the API answers 429 with a Retry-After header in seconds. Each key has its own limit, so two apps with a key each do not slow each other down.

Can I send a survey email through the API?

Yes. POST /surveys/{survey_id}/send emails a live email survey to one person now, and POST /sends reports an order or custom event to surveys that already have an API trigger. Both need the surveys:write scope and sending approval on the account, and they count toward the plan's monthly email allowance.

Can I import responses collected somewhere else?

Yes. POST /responses records a new submission to a live link, email or website survey, with the responses:write scope. Each answer is checked against the published survey first, and an external_id of your own makes a retry safe.

Does the API return customer email addresses?

Only when you allow it twice. The key must be created with contact details switched on, and the request must add include_contact_details=true. Otherwise emails, names and phone numbers are masked, for example em**@ex*****.com.

Can I call the API from a browser?

No. The API sends no CORS headers, so a web page cannot call it and a key never ends up in page source. Call it from your server. To show a survey in a browser, use the website SDK, which needs only a public site key.

Keep reading

Read the spec, then make the first call

The OpenAPI document needs no key. Plus includes the API and starts with a 14-day trial.