Skip to content

Create a question

client.Questions.New(ctx, body) (*QuestionUnion, error)
POST/v5/questions

Create a new question owned by the caller’s account.

The question is one of six types selected by the required question_type discriminator (categorical, rating, number, free_text, form, or timestamp), and each type carries its own configuration block; name and prompt are required for every type. Questions are the reusable units that are grouped into question sets and referenced by rubrics, so create them before assembling a question set. The created question is scoped to the caller’s account and records the creating identity. The question type and its configuration are set at creation time and cannot be changed afterward through the update endpoint.

ParametersExpand Collapse
body QuestionNewParams
Question param.Field[QuestionNewParamsQuestionUnion]
type QuestionNewParamsQuestionCategorical struct{…}
Choices []string

Categorical answer choices (must contain at least one entry)

Multi boolOptional

Whether the question allows multiple answers.

Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

QuestionType stringOptional
type QuestionNewParamsQuestionRating struct{…}
MaxLabel string

Label shown for the maximum rating

MinLabel string

Label shown for the minimum rating

Steps int64

Number of discrete points on the scale (e.g., 5 for a 1–5 scale)

minimum1
Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

QuestionType stringOptional
type QuestionNewParamsQuestionNumber struct{…}
Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration NumberQuestionConfigurationOptional
Max float64Optional

Maximum value for the number

Min float64Optional

Minimum value for the number

QuestionType stringOptional
type QuestionNewParamsQuestionFreeText struct{…}
Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration FreeTextQuestionConfigurationOptional
MaxLength int64Optional

Maximum characters allowed

minimum1
MinLength int64Optional

Minimum characters required

minimum0
QuestionType stringOptional
type QuestionNewParamsQuestionForm struct{…}
FormSchema map[string, any]

The JSON schema of the desired form object

Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

QuestionType stringOptional
type QuestionNewParamsQuestionTimestamp struct{…}
Name string
Prompt string

user-facing question prompt

Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration TimestampQuestionConfigurationOptional
Multi boolOptional

Whether to allow multiple timestamps

QuestionType stringOptional
ReturnsExpand Collapse
type QuestionUnion interface{…}
One of the following:
type CategoricalQuestion struct{…}
ID string

Unique identifier of the entity

Choices []string

Categorical answer choices (must contain at least one entry)

Multi boolOptional

Whether the question allows multiple answers.

CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Object CategoricalQuestionObjectOptional
QuestionType CategoricalQuestionQuestionTypeOptional
type RatingQuestion struct{…}
ID string

Unique identifier of the entity

MaxLabel string

Label shown for the maximum rating

MinLabel string

Label shown for the minimum rating

Steps int64

Number of discrete points on the scale (e.g., 5 for a 1–5 scale)

minimum1
CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Object RatingQuestionObjectOptional
QuestionType RatingQuestionQuestionTypeOptional
type NumberQuestion struct{…}
ID string

Unique identifier of the entity

CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration NumberQuestionConfigurationOptional
Max float64Optional

Maximum value for the number

Min float64Optional

Minimum value for the number

Object NumberQuestionObjectOptional
QuestionType NumberQuestionQuestionTypeOptional
type FreeTextQuestion struct{…}
ID string

Unique identifier of the entity

CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration FreeTextQuestionConfigurationOptional
MaxLength int64Optional

Maximum characters allowed

minimum1
MinLength int64Optional

Minimum characters required

minimum0
Object FreeTextQuestionObjectOptional
QuestionType FreeTextQuestionQuestionTypeOptional
type FormQuestion struct{…}
ID string

Unique identifier of the entity

FormSchema map[string, any]

The JSON schema of the desired form object

CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Object FormQuestionObjectOptional
QuestionType FormQuestionQuestionTypeOptional
type TimestampQuestion struct{…}
ID string

Unique identifier of the entity

CreatedAt Time

ISO-timestamp when the entity was created

formatdate-time
CreatedBy Identity

The identity that created the entity.

ID string
Type IdentityType
One of the following:
const IdentityTypeUser IdentityType = "user"
const IdentityTypeServiceAccount IdentityType = "service_account"
Object IdentityObjectOptional
Name string
Prompt string

user-facing question prompt

ArchivedAt TimeOptional

ISO-timestamp when the entity was archived

formatdate-time
Conditions []map[string, any]Optional

Conditions for the question to be shown

Configuration TimestampQuestionConfigurationOptional
Multi boolOptional

Whether to allow multiple timestamps

Object TimestampQuestionObjectOptional
QuestionType TimestampQuestionQuestionTypeOptional

Create a question

package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  question, err := client.Questions.New(context.TODO(), sgpdev.QuestionNewParams{
    OfCategorical: &sgpdev.QuestionNewParamsQuestionCategorical{
      Configuration: sgpdev.CategoricalQuestionConfigurationParam{
        Choices: []string{"string"},
      },
      Name: "name",
      Prompt: "prompt",
      QuestionType: "categorical",
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", question)
}
{
  "id": "id",
  "configuration": {
    "choices": [
      "string"
    ],
    "dropdown": true,
    "multi": true
  },
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "name": "name",
  "prompt": "prompt",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "conditions": [
    {
      "foo": "bar"
    }
  ],
  "object": "question",
  "question_type": "categorical"
}
Returns Examples
{
  "id": "id",
  "configuration": {
    "choices": [
      "string"
    ],
    "dropdown": true,
    "multi": true
  },
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "name": "name",
  "prompt": "prompt",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "conditions": [
    {
      "foo": "bar"
    }
  ],
  "object": "question",
  "question_type": "categorical"
}