Promo Codes

Manage promo code lists and link them to surveys

Survey promo codes

The promo codes module allows you to restrict access to a survey, run promotions, and track conversions using code lists linked to specific surveys.

Base prefix for most endpoints: /api/v3/service/quiz/{id}/promo and /api/v3/service/promo.

Download the markdown version of the «Promo Codes» section for use in ChatGPT / other LLMs:

All endpoints

HTTP Endpoint Purpose
GET/quiz/{id}/promo/listGet workspace promo code lists
POST/quiz/{id}/promo/listCreate a promo code list
POST/quiz/{id}/promo/list/{list_id}Rename a list
DELETE/quiz/{id}/promo/list/{list_id}Delete a promo code list
GET/promo/codesGet codes of the selected list (global)
POST/promo/codesAdd codes to a list
DELETE/promo/codes/{code_id}Delete a code
POST/promo/listCreate a list (via /promo/list)
POST/promo/import-fileImport codes from file
POST/promo/attach/{list_id}Attach a list to surveys
POST/promo/detachDetach a list from surveys
POST/quiz/{id}/promo/syncSynchronize list attachments
GET/quiz/{id}/promo/codes/quizCodes of the list attached to a survey
GET/quiz/{id}/promo/pinnedSurveys for the attachment screen

Get promo code lists GET /api/v3/service/quiz/{id}/promo/list

Returns a paginated list of workspace promo code lists with the number of codes and attached surveys.

Parameter Type Default Description
searchstringSearch by list name
limitinteger20Count (max 500)
offsetinteger0Offset
sortstringupdated_atid, updated_at, name
orderstringdescasc or desc
GET/api/v3/service/quiz/123/promo/list
curl -X GET "https://api.surveyninja.io/api/v3/service/quiz/123/promo/list?limit=20&offset=0" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json"

Create a promo code list POST /api/v3/service/promo/list

Creates a new list with a set of codes (up to 1000 at a time).

Parameter Req. Description
nameYesList name
codes[]YesArray of promo code strings (up to 1000)
POST/api/v3/service/promo/list
curl -X POST "https://api.surveyninja.io/api/v3/service/promo/list" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "January Sale", "codes": ["PROMO001", "PROMO002", "PROMO003"] }'

Rename a list POST /api/v3/service/quiz/{id}/promo/list/{list_id}

Parameter Req. Description
nameYesNew list name
POST/api/v3/service/quiz/{id}/promo/list/{list_id}
curl -X POST "https://api.surveyninja.io/api/v3/service/quiz/123/promo/list/45" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "February Sale" }'

Delete a list DELETE /api/v3/service/quiz/{id}/promo/list/{list_id}

Deletes a promo code list along with all its codes. No request body required.

DELETE/api/v3/service/quiz/{id}/promo/list/{list_id}
curl -X DELETE "https://api.surveyninja.io/api/v3/service/quiz/123/promo/list/45" \ -H "Authorization: Bearer YOUR_API_TOKEN"

Get list codes GET /api/v3/service/promo/codes

Returns codes of the specified list with filtering and pagination. The response includes the stats and quizzes[] fields.

Parameter Req. Default Description
list_idYesPromo code list ID
searchNoSearch by code
usedNo1 — used, 0 — unused
limitNo20Count (max 500)
offsetNo0Offset
sortNoidid, updated_at, name
orderNodescasc or desc
GET/api/v3/service/promo/codes
curl -X GET "https://api.surveyninja.io/api/v3/service/promo/codes?list_id=45&limit=20" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json"

Add codes to a list POST /api/v3/service/promo/codes

Parameter Req. Description
list_idYesList ID
codes[]YesArray of promo code strings
POST/api/v3/service/promo/codes
curl -X POST "https://api.surveyninja.io/api/v3/service/promo/codes" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "list_id": 45, "codes": ["NEW001", "NEW002"] }'

Delete a code DELETE /api/v3/service/promo/codes/{code_id}

Deletes an individual promo code from the list. No request body required.

DELETE/api/v3/service/promo/codes/{code_id}
curl -X DELETE "https://api.surveyninja.io/api/v3/service/promo/codes/789" \ -H "Authorization: Bearer YOUR_API_TOKEN"

Import codes from file POST /api/v3/service/promo/import-file

Uploads promo codes from a file. Request format: multipart/form-data.

Parameter Req. Description
fileYesFile in txt, csv, xlsx, xls format. Maximum 1 MB

Response: {"imported_count": 50, "codes": ["CODE1", ...]}

POST/api/v3/service/promo/import-file
curl -X POST "https://api.surveyninja.io/api/v3/service/promo/import-file" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "file=@/path/to/codes.csv"

Attach / detach a list from surveys

Manage attaching a promo code list to multiple surveys at once.

Parameter Req. Description
quize_ids[]YesArray of survey IDs
POST/api/v3/service/promo/attach/{list_id}
curl -X POST "https://api.surveyninja.io/api/v3/service/promo/attach/45" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "quize_ids": [123, 456] }'
POST/api/v3/service/promo/detach
curl -X POST "https://api.surveyninja.io/api/v3/service/promo/detach" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "quize_ids": [123] }'

Synchronize attachments POST /api/v3/service/quiz/{id}/promo/sync

Atomically updates list attachments: attaches the specified surveys and detaches all others. Returns lists of changes.

Parameter Req. Description
list_idYesPromo code list ID
quize_ids[]YesFinal list of survey IDs to attach
POST/api/v3/service/quiz/{id}/promo/sync
curl -X POST "https://api.surveyninja.io/api/v3/service/quiz/123/promo/sync" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "list_id": 45, "quize_ids": [123, 456, 789] }'

Response example:

{ "attached": [456, 789], "detached": [100, 101] }

Codes of the attached list GET /api/v3/service/quiz/{id}/promo/codes/quiz

Returns promo codes from the list attached to the specified survey. Similar to GET /promo/codes, but without needing to specify list_id.

GET/api/v3/service/quiz/{id}/promo/codes/quiz
curl -X GET "https://api.surveyninja.io/api/v3/service/quiz/123/promo/codes/quiz" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json"

Surveys for the attachment screen GET /api/v3/service/quiz/{id}/promo/pinned

Returns a list of surveys with a flag indicating whether the specified promo code list is attached to them.

Parameter Req. Default Description
list_idYesPromo code list ID
searchNoSearch by survey name
limitNo20Count
offsetNo0Offset

Response: {"total": N, "data": [{"id": 123, "name": "My Survey", "attach": true, "current": false}, ...]}

GET/api/v3/service/quiz/{id}/promo/pinned
curl -X GET "https://api.surveyninja.io/api/v3/service/quiz/123/promo/pinned?list_id=45&limit=20" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json"