Replace a question
const url = 'https://api.keptslot.com/v1/questions/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"label":"example","help_text":"example","type":"short_text","options":["example"],"required":true,"applies_to":"all_services"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.keptslot.com/v1/questions/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "label": "example", "help_text": "example", "type": "short_text", "options": [ "example" ], "required": true, "applies_to": "all_services" }'This endpoint replaces a question. Send the whole question: an omitted
required becomes false, and an omitted type or applies_to is
rejected with 422.
It does not change the services set with
PUT /v1/questions/{id}/services, and the response has service_ids
as [].
Answers already given keep the label and the answer as they were when the customer answered. A replace does not change them.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The question id.
Request Body required
Section titled “ Request Body required ”A whole question. Create and replace use the same shape.
object
At most 200 characters. Plain text.
At most 500 characters. Plain text.
short_text is one line and long_text is several.
single_select is one choice from options.
The choices of a single_select question: from 2 to 20, none
blank, each at most 200 characters, and all different after
spaces are trimmed from the start and end. For short_text and
long_text, omit it or send []; any choice is rejected with 422
on options.
If you omit it, the question is optional.
all_services asks the question for every service.
selected_services asks it only for the services set with
PUT /v1/questions/{id}/services. Those services have no effect
under all_services.
Responses
Section titled “ Responses ”The question, after the replace.
A question on the booking form, as the workspace manages it. The
Question schema is the customer’s view of the same row, and has no
active.
object
Empty unless type is single_select.
The services set with PUT /v1/questions/{id}/services.
GET /v1/questions and that endpoint return them. Create,
replace, archive and restore always return [] here, whatever
the services are.
Active questions list first, then archived ones; within each, by this value, lowest first.
False when the question is archived. An archived question is not on the booking form.
Example
{ "type": "short_text", "applies_to": "all_services"}The key is missing, malformed or revoked.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}This is a server route and you sent a publishable key. Send a secret
key from your server. The type field is secret_key_required.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}There is no such resource in this workspace.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}The request body or the query is not valid.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}A fault on our side. Do not retry the same request in a loop. The
type field is internal_error.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}