POST
/
v4
/
questions
import SGPClient from 'sgp';

const client = new SGPClient({
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

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

  console.log(question.id);
}

main();
{
  "type": "categorical",
  "title": "<string>",
  "prompt": "<string>",
  "choices": [
    {
      "label": "<string>",
      "value": "<string>",
      "audit_required": false
    }
  ],
  "ratingOptions": {
    "minLabel": "<string>",
    "maxLabel": "<string>",
    "scaleSteps": 123
  },
  "numberOptions": {
    "min": 123,
    "max": 123
  },
  "multi": true,
  "dropdown": true,
  "required": true,
  "conditions": [
    {}
  ],
  "id": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "account_id": "<string>",
  "created_by_user_id": "<string>"
}

Authorizations

x-api-key
string
header
required

Headers

x-selected-account-id
string | null

Body

application/json
type
enum<string>
required

The type of question

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

The ID of the account that owns the given entity.

choices
object[]

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

ratingOptions
object

Options for rating questions.

numberOptions
object

Options for number 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
object[]

Conditions for the question to be shown.

Response

200
application/json
Successful Response
type
enum<string>
required

The type of question

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

The unique identifier of the entity.

created_at
string
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.

choices
object[]

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

ratingOptions
object

Options for rating questions.

numberOptions
object

Options for number 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
object[]

Conditions for the question to be shown.