Consumer Duty: Questions
The Consumer Duty Questions API allows you manage the question sets that users get asked
The Consumer Duty Question Resource
Properties
- Name
- id
- Required
- Type
- integer
- Description
- Unique identifier for the consumer duty question record 
 
- Name
- question
- Required
- Type
- object
- Description
- Name
- type
- Required
- Type
- enum[string]
- Description
- The type of question being asked. Will be either - multiple_choiceor- single. If- multiple_choiceis given, the user can select more than one answer from the list. If- singleis given, the user can only select one answer.
 
- Name
- text
- Required
- Type
- string
- Description
- The question that should be answered by the user. 
 
 
 
- Name
- answers
- Required
- Type
- object[]
- Description
- Name
- key
- Required
- Type
- string
- Description
- A unique key for this answer. This value must be used when saving the answers, in order to identify which answer was selected by the user. 
 
- Name
- text
- Required
- Type
- string
- Description
- The text of an answer the user can select. 
 
- Name
- is_acceptable
- Required
- Type
- boolean
- Description
- Whether the user selecting this answer can be considered a correct answer. 
 
 
 
- Name
- dates
- Required
- Type
- object
- Description
- Name
- created_at
- Required
- Type
- datetime
- Description
- The date the question record was created, represented in - YYYY-MM-DD HH:MM:SSformat
 
- Name
- updated_at
- Required
- Type
- datetime
- Description
- The date the question record was last updated, represented in - YYYY-MM-DD HH:MM:SSformat
 
- Name
- deleted_at
- Required
- Type
- datetime | null
- Description
- The date the question record was deleted, represented in - YYYY-MM-DD HH:MM:SSformat. Will be set to- nullif not deleted.
 
 
 
Consumer Duty Question Resource
{
  "id": 1,
  "question": {
    "type": "multiple_choice",
    "text": "What happens if you don't validate user submitted data to this endpoint?"
  },
  "answers": [
    {
      "key": "dc4a666ba08efb6927bc5e9260e8f23c",
      "text": "Possible SQL injection attacks",
      "is_acceptable": true,
    },
    {
      "key": "57224f8f1789a74d06800a6a24a391db",
      "text": "Nothing, it will be fine",
      "is_acceptable": false
    },
    {
      "key": "4dbeadf6c71dc782ae221851e629e3ab",
      "text": "An angry QA",
      "is_acceptable": true
    }
  ],
  "dates": {
    "created_at": "2024-01-01 00:00:00",
    "updated_at": "2024-01-02 12:00:00",
    "deleted_at": null
  }
}
Search Questions
The search questions endpoint uses the standard Search package from the SDK.
An array of question resources are returned. If no results are found, an empty collection is returned.
Search Filters
- Name
- filters.id.equals
- Required
- Type
- integer
- Description
- Match a single question by ID 
 
- Name
- filters.id.in
- Required
- Type
- integer[]
- Description
- Match multiple questions by an array of IDs 
 
- Name
- filters.type.equals
- Required
- Type
- string
- Description
- Match multiple questions by type. Available values are - multiple_choiceand- single.
 
- Name
- filters.type.in
- Required
- Type
- string[]
- Description
- Match multiple questions by multiple types. Available values are - multiple_choiceand- single.
 
- Name
- filters.is_deleted.equals
- Required
- Type
- boolean
- Description
- Match questions by whether they're deleted or not. By default, not supplying this filter will return deleted and non-deleted questions. 
 
Search Ordering
- id
- type
- created_at / created
- updated_at / updated
- deleted_at / deleted
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
use Compliance\Sdk\Search\Search;
private ApexV3SdkInterface $sdk;
$search = new Search();
$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->questions()
  ->search($search);
Response
{
  "data": [
    {
      "id": 1,
      "question": {
        "type": "single",
        "text": "Whats 7 + 3?"
      },
      "answers": [
        {
          "key": "8f14e45fceea167a5a36dedd4bea2543",
          "text": "7",
          "is_acceptable": false
        },
        {
          "key": "d3d9446802a44259755d38e6d163e820",
          "text": "10",
          "is_acceptable": true
        }
      ],
      "dates": {
        "created_at": "2024-01-01 00:00:00",
        "updated_at": "2024-01-02 12:00:00",
        "deleted_at": null
      }
    }
  ]
}
Retrieve question
Will retrieve a specific question record by ID
URL Parameters
- Name
- question_id
- Required
- required
- Type
- integer
- Description
- ID of the question to retrieve 
 
Error Codes
| Status | Description | 
|---|---|
| 404 | The requested question could not be found | 
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->question(1)
  ->get();
Response
{
  "data": {
    "id": 1,
    "question": {
      "type": "single",
      "text": "Whats 7 + 3?"
    },
    "answers": [
      {
        "key": "8f14e45fceea167a5a36dedd4bea2543",
        "text": "7",
        "is_acceptable": false
      },
      {
        "key": "d3d9446802a44259755d38e6d163e820",
        "text": "10",
        "is_acceptable": true
      }
    ],
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": null
    }
  }
}
Create Question
Create a new single question
Payload
- Name
- question
- Required
- required
- Type
- string
- Description
- The question to ask. All formatting except for new lines will be removed. 
 
- Name
- type
- Required
- required
- Type
- string
- Description
- The type of question this is. If you would like users to be able to select more than one answer, use - multiple_choice. If you would like users to select only a single answer use- single- If you provide - multiple_choiceand provide more than one acceptable answer, all of those answers must be selected for the question to be considered correctly answered.- If you provide - singleand provide more than one acceptable answer, as long as the user has selected one of those answers, the question will be considered correctly answered.
 
- Name
- answers
- Required
- required
- Type
- object[]
- Description
- At least two answers must be provided for all questions. - Name
- text
- Required
- required
- Type
- string
- Description
- The text for one of the answers to provide to the user. All formatting except for new lines will be removed. 
 
- Name
- is_acceptable
- Required
- required
- Type
- boolean
- Description
- Whether this answer should be considered a correct answer. 
 
 
 
Error Codes
| Status | Description | 
|---|---|
| 422 | The data provided in the payload was invalid. See errors for more details. | 
| 422 | If less than 2 answers are provided | 
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->create(
    'What is 7 + 3?',
    'single',
    [
      [
        'text' => '9',
        'is_acceptable' => false,
      ],
      [
        'text' => '10',
        'is_acceptable' => true,
      ],
    ],
  ]);
Response
{
  "data": {
    "id": 1,
    "question": {
      "type": "single",
      "text": "Whats 7 + 3?"
    },
    "answers": [
      {
        "key": "45c48cce2e2d7fbdea1afc51c7c6ad26",
        "text": "9",
        "is_acceptable": false
      },
      {
        "key": "d3d9446802a44259755d38e6d163e820",
        "text": "10",
        "is_acceptable": true
      }
    ],
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": null
    }
  }
}
Delete Question
Deletes an existing question. Once deleted, this question will no longer be provided to the user to select, but existing answers to it will be kept.
URL Parameters
- Name
- question_id
- Required
- required
- Type
- integer
- Description
- ID of the question to delete 
 
Error Codes
| Status | Description | 
|---|---|
| 404 | The requested question could not be found | 
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->question(1)
  ->delete();
Response
{
  "data": {
    "id": 1,
    "question": {
      "type": "single",
      "text": "Whats 7 + 3?"
    },
    "answers": [
      {
        "key": "8f14e45fceea167a5a36dedd4bea2543",
        "text": "7",
        "is_acceptable": false
      },
      {
        "key": "d3d9446802a44259755d38e6d163e820",
        "text": "10",
        "is_acceptable": true
      }
    ],
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": "2025-01-01 00:00:00"
    }
  }
}