Skip to content

Update a question

client.Questions.Update(ctx, questionID, body) (*QuestionUnion, error)
PATCH/v5/questions/{question_id}

Update a question’s display name.

Only the name is mutable through this endpoint; a question’s type, prompt, and type-specific configuration are fixed at creation and cannot be changed here. Updating an archived question is rejected with a client error, so restore it first if it needs to be edited. The update is scoped to the caller’s account.

ParametersExpand Collapse
questionID string
body QuestionUpdateParams
Name param.Field[string]

Display name for the question

maxLength255
minLength1
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

Update 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.Update(
    context.TODO(),
    "question_id",
    sgpdev.QuestionUpdateParams{
      Name: "x",
    },
  )
  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"
}