curl --request PATCH \
--url https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedDraftVersion": 7,
"operations": [
{
"op": "add_question",
"question": {
"ref": "q3",
"type": "multiple_choice",
"text": "Which plan are you on?",
"options": [
"Free",
"Pro"
]
},
"after": null
},
{
"op": "update_question",
"questionId": "a0000000-0000-4000-8000-000000000005",
"set": {
"text": "How likely are you to recommend Usertick to a friend?"
}
},
{
"op": "set_targeting",
"set": {
"trigger": {
"type": "scroll",
"percent": 50
}
}
}
]
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedDraftVersion: 7,
operations: [
{
op: 'add_question',
question: {
ref: 'q3',
type: 'multiple_choice',
text: 'Which plan are you on?',
options: ['Free', 'Pro']
},
after: null
},
{
op: 'update_question',
questionId: 'a0000000-0000-4000-8000-000000000005',
set: {text: 'How likely are you to recommend Usertick to a friend?'}
},
{op: 'set_targeting', set: {trigger: {type: 'scroll', percent: 50}}}
]
})
};
fetch('https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft"
payload = {
"expectedDraftVersion": 7,
"operations": [
{
"op": "add_question",
"question": {
"ref": "q3",
"type": "multiple_choice",
"text": "Which plan are you on?",
"options": ["Free", "Pro"]
},
"after": None
},
{
"op": "update_question",
"questionId": "a0000000-0000-4000-8000-000000000005",
"set": { "text": "How likely are you to recommend Usertick to a friend?" }
},
{
"op": "set_targeting",
"set": { "trigger": {
"type": "scroll",
"percent": 50
} }
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)Edit a survey draft
Edits a survey that was never published: 1 to 50 operations (add_question with after, update_question that changes only the fields sent, remove_question, move_question, set_survey, set_targeting), applied in order and saved together or not at all. Nothing goes live: a person publishes the draft in Usertick (editorUrl). The questions are checked the way a dashboard save checks them, each error naming its field, and the plan’s limits apply as in the dashboard; no Usertick AI credits are used. Send expectedDraftVersion from the last read: a draft that changed since is 409 PUB-008-004 (read it again and redo the edit). While the survey is open in the Usertick editor the edit is 409 PUB-008-003 (ask the person to close it). A live, paused or archived survey is 409 PUB-008-005: its changes are made in the dashboard. Removing a question leaves a rule that jumped to it without a destination, as the editor does. Answers with the draft.
Scopes: surveys:draft, surveys:read.
curl --request PATCH \
--url https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expectedDraftVersion": 7,
"operations": [
{
"op": "add_question",
"question": {
"ref": "q3",
"type": "multiple_choice",
"text": "Which plan are you on?",
"options": [
"Free",
"Pro"
]
},
"after": null
},
{
"op": "update_question",
"questionId": "a0000000-0000-4000-8000-000000000005",
"set": {
"text": "How likely are you to recommend Usertick to a friend?"
}
},
{
"op": "set_targeting",
"set": {
"trigger": {
"type": "scroll",
"percent": 50
}
}
}
]
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expectedDraftVersion: 7,
operations: [
{
op: 'add_question',
question: {
ref: 'q3',
type: 'multiple_choice',
text: 'Which plan are you on?',
options: ['Free', 'Pro']
},
after: null
},
{
op: 'update_question',
questionId: 'a0000000-0000-4000-8000-000000000005',
set: {text: 'How likely are you to recommend Usertick to a friend?'}
},
{op: 'set_targeting', set: {trigger: {type: 'scroll', percent: 50}}}
]
})
};
fetch('https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.usertick.com/api/public/v1/surveys/{surveyId}/draft"
payload = {
"expectedDraftVersion": 7,
"operations": [
{
"op": "add_question",
"question": {
"ref": "q3",
"type": "multiple_choice",
"text": "Which plan are you on?",
"options": ["Free", "Pro"]
},
"after": None
},
{
"op": "update_question",
"questionId": "a0000000-0000-4000-8000-000000000005",
"set": { "text": "How likely are you to recommend Usertick to a friend?" }
},
{
"op": "set_targeting",
"set": { "trigger": {
"type": "scroll",
"percent": 50
} }
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)Authorizations
Headers
Any 1 to 255 printable ASCII characters, without a space at either end. The answer to the first request with a key is kept for 24 hours per credential: the same request again gets it back (Idempotent-Replayed: true), another request with the key is 409 PUB-002-002, and while the first still runs 409 PUB-002-003. A server error is not kept, and a request that never answered frees its key after 2 minutes: a retry with the key then runs again.
255Body
Response
The draft after the edit.