Skip to main content
POST
/
v4
/
questions
JavaScript
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: 'My API Key',
});

const question = await client.questions.create({
  account_id: 'account_id',
  prompt: 'prompt',
  title: 'title',
  type: 'categorical',
});

console.log(question.id);
{
  "type": "categorical",
  "title": "<string>",
  "prompt": "<string>",
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "account_id": "<string>",
  "created_by_user_id": "<string>",
  "created_by_identity_type": "user",
  "choices": [
    {
      "label": "<string>",
      "value": "<string>",
      "audit_required": false
    }
  ],
  "ratingOptions": {
    "minLabel": "<string>",
    "maxLabel": "<string>",
    "scaleSteps": 123
  },
  "numberOptions": {
    "min": 123,
    "max": 123
  },
  "freeTextOptions": {
    "characterLimit": {
      "min": 50,
      "max": 1000
    }
  },
  "multi": true,
  "dropdown": true,
  "required": true,
  "conditions": [
    {}
  ],
  "default": "<unknown>",
  "form_schema": {}
}

Authorizations

x-api-key
string
header
required

Headers

x-selected-account-id
string

Body

application/json
type
enum<string>
required

The type of question

Available options:
categorical,
free_text,
rating,
number,
form,
timestamp
title
string
required
prompt
string
required
account_id
string
required

The ID of the account that owns the given entity.

choices
CategoricalChoice · object[]

List of choices for the question. Required for CATEGORICAL questions.

ratingOptions
RatingQuestionOptions · object

Options for rating questions.

numberOptions
NumberQuestionOptions · object

Options for number questions.

freeTextOptions
FreeTextQuestionOptions · object

Options for free text questions.

multi
boolean

Whether the question allows multiple answers. For categorical questions, this enables multi-select. For timestamp questions, this allows multiple timestamps.

dropdown
boolean

Whether the question is displayed as a dropdown in the UI.

required
boolean

[To be deprecated in favor of question set question_id_to_config] Whether the question is required.

conditions
Conditions · object[]

Conditions for the question to be shown.

default
any

The default value for the question.

form_schema
Form Schema · object

The schema for the question.

allowMultiTimestamps
boolean

Whether to allow multiple media timestamps for timestamp questions.

Response

Successful Response

type
enum<string>
required

The type of question

Available options:
categorical,
free_text,
rating,
number,
form,
timestamp
title
string
required
prompt
string
required
id
string
required

The unique identifier of the entity.

created_at
string<date-time>
required

The date and time when the entity was created in ISO format.

account_id
string
required

The ID of the account that owns the given entity.

created_by_user_id
string
required

The user who originally created the entity.

created_by_identity_type
enum<string>
required

The type of identity that created the entity.

Available options:
user,
service_account
choices
CategoricalChoice · object[]

List of choices for the question. Required for CATEGORICAL questions.

ratingOptions
RatingQuestionOptions · object

Options for rating questions.

numberOptions
NumberQuestionOptions · object

Options for number questions.

freeTextOptions
FreeTextQuestionOptions · object

Options for free text questions.

multi
boolean

Whether the question allows multiple answers.

dropdown
boolean

Whether the question is displayed as a dropdown in the UI.

required
boolean

[To be deprecated in favor of question set question_id_to_config] Whether the question is required.

conditions
Conditions · object[]

Conditions for the question to be shown.

default
any

The default value for the question.

form_schema
Form Schema · object

The schema for the question.