Consumer Duty: User Question Answers

The Consumer Duty User Question Answers API allows you manage the user responses to questions

User Question records are only created after the user has either correctly or incorrectly answered.


The Consumer Duty User Question Answer Resource

Properties

  • Name
    id
    Required
    Type
    integer
    Description

    Unique identifier for the consumer duty user question record

  • Name
    user_id
    Required
    Type
    integer
    Description

    ID of the user who answered the question

  • Name
    question_id
    Required
    Type
    integer
    Description

    ID of the question which was answered

  • Name
    dealer_id
    Required
    Type
    integer
    Description

    ID of the dealer that the user was acting on behalf of when the question was answered

  • Name
    group_id
    Required
    Type
    integer
    Description

    ID of the group the user was acting on behalf of when the question was answered

  • Name
    answered_correctly
    Required
    Type
    boolean
    Description

    If true, the user provided the correct answer or answers. If false the user didn't provide the correct answer or answers.

  • Name
    dates
    Required
    Type
    object
    Description
    • Name
      user_confirmed_at
      Required
      Type
      null | datetime
      Description

      The date the user confirmed their answer was either correct or incorrect, represented in YYYY-MM-DD HH:MM:SS format. Users will save their answer using the "save answer" endpoint request. This endpoint returns whether the answer is answered correctly or not, at which point they have to confirm they understand. If this value is null, they have submitted an answer to the question, but not confirmed they understand the answer is correct or incorrect.

    • Name
      created_at
      Required
      Type
      datetime
      Description

      The date the answer record was created, represented in YYYY-MM-DD HH:MM:SS format

    • Name
      updated_at
      Required
      Type
      datetime
      Description

      The date the answer record was last updated, represented in YYYY-MM-DD HH:MM:SS format

Consumer Duty User Question Resource

{
  "id": 1,
  "question_id": 2,
  "user_id": 12345,
  "dealer_id": 12935,
  "group_id": 1,
  "answered_correctly": true,
  "dates": {
    "user_confirmed_at": "2024-01-02 12:00:00",
    "created_at": "2024-01-01 00:00:00",
    "updated_at": "2024-01-02 12:00:00"
  }
}

GET/v2/consumer-duty/questions/answers

Search User Answers

The search user question answers endpoint uses the standard Search package from the SDK.

An array of user question answer 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 user question answer by ID

  • Name
    filters.id.in
    Required
    Type
    integer[]
    Description

    Match multiple user question answer by an array of IDs

  • Name
    filters.user_id.equals
    Required
    Type
    integer
    Description

    Find all answers for a given user ID

  • Name
    filters.user_id.in
    Required
    Type
    integer[]
    Description

    Find all answers for multiple given user IDs

  • Name
    filters.dealer_id.equals
    Required
    Type
    integer
    Description

    Find all answers for a given dealer ID

  • Name
    filters.dealer_id.in
    Required
    Type
    integer[]
    Description

    Find all answers for multiple given dealer IDs.

  • Name
    filters.group_id.equals
    Required
    Type
    integer
    Description

    Find all answers for a given group ID

  • Name
    filters.group_id.in
    Required
    Type
    integer[]
    Description

    Find all answers for multiple given group IDs.

  • Name
    filters.question_id.equals
    Required
    Type
    integer
    Description

    Find all answers for a given question ID

  • Name
    filters.question_id.in
    Required
    Type
    integer[]
    Description

    Find all answers for multiple given question IDs.

  • Name
    filters.answered_correctly.equals
    Required
    Type
    boolean
    Description

    If true provided, will return all answer records that were answered correctly. If false provided, will return all answer records that were answered incorrectly. If this filter is not provided, will return all answers regardless of if they were answered correctly or not.

  • Name
    filters.is_confirmed.equals
    Required
    Type
    boolean
    Description

    If true is provided, will return all answer records which have been confirmed by the user. If false is provided, will return all answer records which have not been confirmed by the user.

Search Ordering

  • id
  • question_id
  • user_id
  • dealer_id
  • group_id
  • answered_correctly
  • user_confirmed_at / user_confirmed / confirmed
  • created_at / created
  • updated_at / updated

Request

GET
/v2/consumer-duty/questions/answers
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()
  ->answers()
  ->search($search);

Response

{
  "data": [
    {
      "id": 1,
      "question_id": 2,
      "user_id": 12345,
      "dealer_id": 12935,
      "group_id": 1,
      "answered_correctly": true,
      "dates": {
        "user_confirmed_at": "2024-01-02 12:00:00",
        "created_at": "2024-01-01 00:00:00",
        "updated_at": "2024-01-02 12:00:00"
      }
    }
  ]
}

GET/v2/consumer-duty/questions/answers/:answer_id

Retrieve answer

Will retrieve a specific answer record for a given ID

URL Parameters

  • Name
    answer
    Required
    required
    Type
    integer
    Description

    ID of answer to retrieve

Error Codes

Status Description
404 The requested answer could not be found

Request

GET
/v2/consumer-duty/questions/answers/:answer_id
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->questions()
  ->answer(1)
  ->get();

Response

{
  "data": {
    "id": 1,
    "question_id": 2,
    "user_id": 12345,
    "dealer_id": 12935,
    "group_id": 1,
    "answered_correctly": true,
    "dates": {
      "user_confirmed_at": "2024-01-02 12:00:00",
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00"
    }
  }
}

POST/v2/consumer-duty/questions/answers

Save Answer

Stores the users answer to a question.

An answer will be marked as correct under the following circumstances:

  • The question type is multiple_choice, there are multiple acceptable answers, and they have all been selected
  • The question type is multiple_choice, there is one acceptable answer, and it has been selected
  • The question type is multiple_choice, there are no acceptable answers, and an empty array of answers has been provided to this endpoint
  • The question type is single, there are multiple acceptable answer, and the user has selected one of those acceptable answers
  • The question type is single, there is one acceptable answer and the it has been selected
  • The question type is single there are no acceptable answers, and an empty array of answers has been provided to this endpoint

An answer will be marked as incorrect if all of the above conditions are false, or:

  • The question type is multiple_choice, there are multiple acceptable answers and the user has not selected them all
  • The question type is multiple_choice, and the user has selected more answers than are accepted, regardless of if any acceptable answers were chosen.

Relating to the last point, if the question is "what is 5 + 5?" with the available answers "5" or "10", if the user selects both answers this will be considered incorrect.

Payload

  • Name
    question_id
    Required
    required
    Type
    integer
    Description

    The ID of the question being answered

  • Name
    user_id
    Required
    required
    Type
    integer
    Description

    The ID of the user who is answering the question

  • Name
    dealer_id
    Required
    required
    Type
    integer
    Description

    ID of the dealer the user is acting on behalf of when answering the question

  • Name
    answers
    Required
    required
    Type
    string[]
    Description

    An array of answers. The values provided must be the key value returned in the answers object of the question. This must always be provided as an array of answers.

Error Codes

Status Description
404 If the question being answered doesn't exist, or is deleted
404 If the user answering the question cannot be found.
404 If the dealer the user is acting on behalf of cant be found.
409 If the question type is multiple_choice and more than one answer has been provided.
409 When trying to save the answer to a question, when a previous answer has not been confirmed.
422 The data provided in the payload was invalid. See errors for more details.
422 If an answer is provided which isn't a stored answer for the question

Request

POST
/v2/consumer-duty/questions/answers
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->questions()
  ->answers()
  ->create(
    1,
    2,
    3,
    [
      'dc4a666ba08efb6927bc5e9260e8f23c',
      '57224f8f1789a74d06800a6a24a391db',
    ]
  ]);

Response

{
  "data": {
    "id": 1,
    "question_id": 1,
    "user_id": 2,
    "dealer_id": 3,
    "group_id": 1,
    "answered_correctly": true,
    "dates": {
      "user_confirmed_at": null,
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00"
    }
  }
}

POST/v2/consumer-duty/questions/answers/1/confirm

Confirm Answer

Marks that the user has confirmed they got the question correct or incorrect.

URL Parameters

  • Name
    answer_id
    Required
    required
    Type
    integer
    Description

    ID of the answer to mark as confirmed

Error Codes

Status Description
404 If the answer being confirmed doesn't exist

Request

POST
/v2/consumer-duty/questions/answers/1/confirm
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->consumerDuty()
  ->questions()
  ->answer(1)
  ->confirm();

Response

{
  "data": {
    "id": 1,
    "question_id": 1,
    "user_id": 2,
    "dealer_id": 3,
    "group_id": 1,
    "answered_correctly": true,
    "dates": {
      "user_confirmed_at": "2024-01-02 12:00:00",
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00"
    }
  }
}