## Update a question

`client.questions.update(stringquestionID, QuestionUpdateParamsbody, RequestOptionsoptions?): Question`

**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.

### Parameters

- `questionID: string`

- `body: QuestionUpdateParams`

  - `name: string`

    Display name for the question

### Returns

- `Question = CategoricalQuestion | RatingQuestion | NumberQuestion | 3 more`

  - `CategoricalQuestion`

    - `id: string`

      Unique identifier of the entity

    - `configuration: CategoricalQuestionConfiguration`

      - `choices: Array<string>`

        Categorical answer choices (must contain at least one entry)

      - `dropdown?: boolean`

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

      - `multi?: boolean`

        Whether the question allows multiple answers.

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

      - `id: string`

      - `type: "user" | "service_account"`

        - `"user"`

        - `"service_account"`

      - `object?: "identity"`

        - `"identity"`

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `object?: "question"`

      - `"question"`

    - `question_type?: "categorical"`

      - `"categorical"`

  - `RatingQuestion`

    - `id: string`

      Unique identifier of the entity

    - `configuration: RatingQuestionConfiguration`

      - `max_label: string`

        Label shown for the maximum rating

      - `min_label: string`

        Label shown for the minimum rating

      - `steps: number`

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

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `object?: "question"`

      - `"question"`

    - `question_type?: "rating"`

      - `"rating"`

  - `NumberQuestion`

    - `id: string`

      Unique identifier of the entity

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `configuration?: NumberQuestionConfiguration`

      - `max?: number`

        Maximum value for the number

      - `min?: number`

        Minimum value for the number

    - `object?: "question"`

      - `"question"`

    - `question_type?: "number"`

      - `"number"`

  - `FreeTextQuestion`

    - `id: string`

      Unique identifier of the entity

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `configuration?: FreeTextQuestionConfiguration`

      - `max_length?: number`

        Maximum characters allowed

      - `min_length?: number`

        Minimum characters required

    - `object?: "question"`

      - `"question"`

    - `question_type?: "free_text"`

      - `"free_text"`

  - `FormQuestion`

    - `id: string`

      Unique identifier of the entity

    - `configuration: FormQuestionConfiguration`

      - `form_schema: Record<string, unknown>`

        The JSON schema of the desired form object

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `object?: "question"`

      - `"question"`

    - `question_type?: "form"`

      - `"form"`

  - `TimestampQuestion`

    - `id: string`

      Unique identifier of the entity

    - `created_at: string`

      ISO-timestamp when the entity was created

    - `created_by: Identity`

      The identity that created the entity.

    - `name: string`

    - `prompt: string`

      user-facing question prompt

    - `archived_at?: string`

      ISO-timestamp when the entity was archived

    - `conditions?: Array<Record<string, unknown>>`

      Conditions for the question to be shown

    - `configuration?: TimestampQuestionConfiguration`

      - `multi?: boolean`

        Whether to allow multiple timestamps

    - `object?: "question"`

      - `"question"`

    - `question_type?: "timestamp"`

      - `"timestamp"`

### Example

```typescript
import SGPClient from 'scale-gp';

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

const question = await client.questions.update('question_id', { name: 'x' });

console.log(question);
```

#### Response

```json
{
  "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"
}
```
