API Documentation
Build fast integrations with the NPS API. Base URL: /api
Authentication: Use
Authorization: Bearer <API_TOKEN> for API requests.
Try with your token
Paste your token below and use it in your terminal commands.
Endpoints overview
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /api/campaigns | Bearer token | List campaigns |
GET | /api/campaigns/{id} | Bearer token | Get campaign by id |
POST | /api/campaigns | Bearer token | Create campaign |
GET | /api/metrics | Bearer token | Get overall metrics |
POST | /api/responses | Respondent token | Submit response |
How to get a user API token
- Log in to the NPS app.
- Go to Settings.
- In API Tokens, enter a token name and click Generate.
- Copy the token immediately (it is only shown once).
How to use the API
Include your token in the Authorization header:
Authorization: Bearer YOUR_API_TOKEN
List campaigns
curl -X GET "http://localhost:8080/api/campaigns" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Get a campaign by id
curl -X GET "http://localhost:8080/api/campaigns/1" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Create a campaign
curl -X POST "http://localhost:8080/api/campaigns" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Q1 NPS",
"description": "First quarter survey"
}'
Submit a response (public survey token)
curl -X POST "http://localhost:8080/api/responses?token=RESPONDENT_TOKEN&rating=10&comment=Great"
Get overall metrics
curl -X GET "http://localhost:8080/api/metrics" \
-H "Authorization: Bearer YOUR_API_TOKEN"