# Challenge Resource

The `Challenge` resource is currently used by Verify Push and Verify TOTP features. It represents a single verification attempt of an [Entity](/docs/verify/api/entity) using a `Factor`. When the `factor_type` is `push`, a `Challenge` is created to verify the signature of the message sent from the registered device with the public key stored in the `Factor`. When the `factor_type` is totp, a `Challenge` is created to verify that the TOTP code provided by the user matches the one generated by the seed stored in the Factor. Some `Challenge` properties apply to all `factor_types` and others do not. A single `Entity` links to multiple `Factors` and a single `Factor` links to multiple `Challenges`.

Verify Push and Verify TOTP are charged per verification:

* Verify Push is charged when a `Challenge` resource with `factor_type: push` is approved (`status: approved`) or denied (`status: denied`).
* Verify TOTP is charged when a `Challenge` resource with `factor_type: totp` is approved (`status: approved`).

Learn more about [Verify pricing](https://www.twilio.com/en-us/verify/pricing).

## Challenge Properties

```json
{"type":"object","refName":"verify.v2.service.entity.challenge","modelName":"verify_v2_service_entity_challenge","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YC[0-9a-fA-F]{32}$","nullable":true,"description":"A 34 character string that uniquely identifies this Challenge."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Account."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Service."},"entity_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YE[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Entity."},"identity":{"type":"string","nullable":true,"description":"Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"factor_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YF[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Factor."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_updated":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"date_responded":{"type":"string","format":"date-time","nullable":true,"description":"The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."},"expiration_date":{"type":"string","format":"date-time","nullable":true,"description":"The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation."},"status":{"type":"string","enum":["pending","expired","approved","denied"],"description":"The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.","refName":"challenge_enum_challenge_statuses","modelName":"challenge_enum_challenge_statuses"},"responded_reason":{"type":"string","enum":["none","not_needed","not_requested"],"description":"Reason for the Challenge to be in certain `status`. One of `none`, `not_needed` or `not_requested`.","refName":"challenge_enum_challenge_reasons","modelName":"challenge_enum_challenge_reasons"},"details":{"nullable":true,"description":"Details provided to give context about the Challenge. Intended to be shown to the end user.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"hidden_details":{"nullable":true,"description":"Details provided to give context about the Challenge. Intended to be hidden from the end user. It must be a stringified JSON with only strings values eg. `{\"ip\": \"172.168.1.234\"}`","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"metadata":{"nullable":true,"description":"Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"factor_type":{"type":"string","enum":["push","totp","passkeys"],"description":"The Factor Type of this Challenge. Currently `push` and `totp` are supported.","refName":"challenge_enum_factor_types","modelName":"challenge_enum_factor_types"},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."},"links":{"type":"object","format":"uri-map","nullable":true,"description":"Contains a dictionary of URL links to nested resources of this Challenge."}}}
```

## Create a Challenge resource

`POST https://verify.twilio.com/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true},{"name":"Identity","in":"path","description":"Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateChallengeRequest","required":["FactorSid"],"properties":{"FactorSid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YF[0-9a-fA-F]{32}$","description":"The unique SID identifier of the Factor."},"ExpirationDate":{"type":"string","format":"date-time","description":"The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation."},"Details.Message":{"type":"string","description":"Shown to the user when the push notification arrives. Required when `factor_type` is `push`. Can be up to 256 characters in length"},"Details.Fields":{"type":"array","description":"A list of objects that describe the Fields included in the Challenge. Each object contains the label and value of the field, the label can be up to 36 characters in length and the value can be up to 128 characters in length. Used when `factor_type` is `push`. There can be up to 20 details fields."},"HiddenDetails":{"description":"Details provided to give context about the Challenge. Not shown to the end user. It must be a stringified JSON with only strings values eg. `{\"ip\": \"172.168.1.234\"}`. Can be up to 1024 characters in length","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"AuthPayload":{"type":"string","description":"Optional payload used to verify the Challenge upon creation. Only used with a Factor of type `totp` to carry the TOTP code that needs to be verified. For `TOTP` this value must be between 3 and 8 characters long."}}},"examples":{"createPush":{"value":{"lang":"json","value":"{\n  \"FactorSid\": \"YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\"\n}","meta":"","code":"{\n  \"FactorSid\": \"YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ExpirationDate\"","#7EE787"],[":","#C9D1D9"]," ",["\"2015-07-30T20:00:00Z\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Message\"","#7EE787"],[":","#C9D1D9"]," ",["\"Hi! Mr. John Doe, would you like to sign up?\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Fields\"","#7EE787"],[": [","#C9D1D9"],"\n    ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["label","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Action","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"]," ",["\\\"","#79C0FF"],["value","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Sign up in portal","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n  ",["],","#C9D1D9"],"\n  ",["\"HiddenDetails\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["ip","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["172.168.1.234","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"createTotpWithoutAuthPayload":{"value":{"lang":"json","value":"{\n  \"FactorSid\": \"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\"\n}","meta":"","code":"{\n  \"FactorSid\": \"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ExpirationDate\"","#7EE787"],[":","#C9D1D9"]," ",["\"2015-07-30T20:00:00Z\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Message\"","#7EE787"],[":","#C9D1D9"]," ",["\"Hi! Mr. John Doe, would you like to sign up?\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Fields\"","#7EE787"],[": [","#C9D1D9"],"\n    ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["label","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Action","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"]," ",["\\\"","#79C0FF"],["value","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Sign up in portal","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n  ",["],","#C9D1D9"],"\n  ",["\"HiddenDetails\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["ip","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["172.168.1.234","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"createTotpWithAuthPayload":{"value":{"lang":"json","value":"{\n  \"FactorSid\": \"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\",\n  \"AuthPayload\": \"12345678\"\n}","meta":"","code":"{\n  \"FactorSid\": \"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n  \"ExpirationDate\": \"2015-07-30T20:00:00Z\",\n  \"Details.Message\": \"Hi! Mr. John Doe, would you like to sign up?\",\n  \"Details.Fields\": [\n    \"{\\\"label\\\": \\\"Action\\\", \\\"value\\\": \\\"Sign up in portal\\\"}\"\n  ],\n  \"HiddenDetails\": \"{\\\"ip\\\": \\\"172.168.1.234\\\"}\",\n  \"AuthPayload\": \"12345678\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorSid\"","#7EE787"],[":","#C9D1D9"]," ",["\"YF02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"ExpirationDate\"","#7EE787"],[":","#C9D1D9"]," ",["\"2015-07-30T20:00:00Z\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Message\"","#7EE787"],[":","#C9D1D9"]," ",["\"Hi! Mr. John Doe, would you like to sign up?\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Details.Fields\"","#7EE787"],[": [","#C9D1D9"],"\n    ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["label","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Action","#A5D6FF"],["\\\"","#79C0FF"],[",","#A5D6FF"]," ",["\\\"","#79C0FF"],["value","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Sign up in portal","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n  ",["],","#C9D1D9"],"\n  ",["\"HiddenDetails\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["ip","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["172.168.1.234","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"AuthPayload\"","#7EE787"],[":","#C9D1D9"]," ",["\"12345678\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create Push Challenge

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createChallenge() {
  const challenge = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("ff483d1ff591898a9942916050d2ca3f")
    .challenges.create({
      "details.fields": [
        {
          label: "Action",
          value: "Sign up in portal",
        },
        {
          label: "Location",
          value: "California",
        },
      ],
      "details.message": "Hi! Mr. John Doe, would you like to sign up?",
      factorSid: "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      hiddenDetails: {
        ip: "127.0.0.1",
      },
    });

  console.log(challenge.sid);
}

createChallenge();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

challenge = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("ff483d1ff591898a9942916050d2ca3f")
    .challenges.create(
        details_message="Hi! Mr. John Doe, would you like to sign up?",
        details_fields=[
            {"label": "Action", "value": "Sign up in portal"},
            {"label": "Location", "value": "California"},
        ],
        hidden_details={"ip": "127.0.0.1"},
        factor_sid="YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    )
)

print(challenge.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service.Entity;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var challenge = await ChallengeResource.CreateAsync(
            detailsMessage: "Hi! Mr. John Doe, would you like to sign up?",
            detailsFields: new List<
                Object> { new Dictionary<string, Object>() { { "label", "Action" }, { "value", "Sign up in portal" } }, new Dictionary<string, Object>() { { "label", "Location" }, { "value", "California" } } },
            hiddenDetails: new Dictionary<string, Object>() { { "ip", "127.0.0.1" } },
            factorSid: "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathIdentity: "ff483d1ff591898a9942916050d2ca3f");

        Console.WriteLine(challenge.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.entity.Challenge;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Challenge challenge = Challenge
                                  .creator("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                                      "ff483d1ff591898a9942916050d2ca3f",
                                      "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                  .setDetailsMessage("Hi! Mr. John Doe, would you like to sign up?")
                                  .setDetailsFields(Arrays.asList(
                                      new HashMap<String, Object>() {
                                          {
                                              put("label", "Action");
                                              put("value", "Sign up in portal");
                                          }
                                      },
                                      new HashMap<String, Object>() {
                                          {
                                              put("label", "Location");
                                              put("value", "California");
                                          }
                                      }))
                                  .setHiddenDetails(new HashMap<String, Object>() {
                                      {
                                          put("ip", "127.0.0.1");
                                      }
                                  })
                                  .create();

        System.out.println(challenge.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &verify.CreateChallengeParams{}
	params.SetDetailsMessage("Hi! Mr. John Doe, would you like to sign up?")
	params.SetDetailsFields([]interface{}{
		map[string]interface{}{
			"label": "Action",
			"value": "Sign up in portal",
		},
		map[string]interface{}{
			"label": "Location",
			"value": "California",
		},
	})
	params.SetHiddenDetails(map[string]interface{}{
		"ip": "127.0.0.1",
	})
	params.SetFactorSid("YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

	resp, err := client.VerifyV2.CreateChallenge("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ff483d1ff591898a9942916050d2ca3f",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$challenge = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->entities("ff483d1ff591898a9942916050d2ca3f")
    ->challenges->create(
        "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", // FactorSid
        [
            "detailsMessage" => "Hi! Mr. John Doe, would you like to sign up?",
            "detailsFields" => [
                [
                    "label" => "Action",
                    "value" => "Sign up in portal",
                ],
                [
                    "label" => "Location",
                    "value" => "California",
                ],
            ],
            "hiddenDetails" => [
                "ip" => "127.0.0.1",
            ],
        ]
    );

print $challenge->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

challenge = @client
            .verify
            .v2
            .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .entities('ff483d1ff591898a9942916050d2ca3f')
            .challenges
            .create(
              details_message: 'Hi! Mr. John Doe, would you like to sign up?',
              details_fields: [
                {
                  'label' => 'Action',
                  'value' => 'Sign up in portal'
                },
                {
                  'label' => 'Location',
                  'value' => 'California'
                }
              ],
              hidden_details: {
                'ip' => '127.0.0.1'
              },
              factor_sid: 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
            )

puts challenge.sid
```

```bash
EXCLAMATION_MARK='!'
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:entities:challenges:create \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity ff483d1ff591898a9942916050d2ca3f \
   --details.message "Hi$EXCLAMATION_MARK Mr. John Doe, would you like to sign up?" \
   --details.fields "{\"label\":\"Action\",\"value\":\"Sign up in portal\"}" "{\"label\":\"Location\",\"value\":\"California\"}" \
   --hidden-details "{\"ip\":\"127.0.0.1\"}" \
   --factor-sid YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
EXCLAMATION_MARK='!'

HIDDEN_DETAILS_OBJ=$(cat << EOF
{
  "ip": "127.0.0.1"
}
EOF
)
curl -X POST "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges" \
--data-urlencode "Details.Message=Hi$EXCLAMATION_MARK Mr. John Doe, would you like to sign up?" \
--data-urlencode "Details.Fields={\"label\":\"Action\",\"value\":\"Sign up in portal\"}" \
--data-urlencode "Details.Fields={\"label\":\"Location\",\"value\":\"California\"}" \
--data-urlencode "HiddenDetails=$HIDDEN_DETAILS_OBJ" \
--data-urlencode "FactorSid=YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_sid": "YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "ff483d1ff591898a9942916050d2ca3f",
  "factor_sid": "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "date_responded": "2015-07-30T20:00:00Z",
  "expiration_date": "2015-07-30T20:00:00Z",
  "status": "pending",
  "responded_reason": "none",
  "details": {
    "message": "Hi! Mr. John Doe, would you like to sign up?",
    "date": "2020-07-01T12:13:14Z",
    "fields": [
      {
        "label": "Action",
        "value": "Sign up in portal"
      }
    ]
  },
  "hidden_details": {
    "ip": "127.0.0.1"
  },
  "metadata": null,
  "factor_type": "push",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "notifications": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications"
  }
}
```

Create TOTP Challenge With AuthPayload

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createChallenge() {
  const challenge = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("ff483d1ff591898a9942916050d2ca3f")
    .challenges.create({
      authPayload: "12345678",
      "details.fields": [
        {
          label: "Action",
          value: "Sign up in portal",
        },
        {
          label: "Location",
          value: "California",
        },
      ],
      "details.message": "Hi! Mr. John Doe, would you like to sign up?",
      factorSid: "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      hiddenDetails: {
        ip: "127.0.0.1",
      },
    });

  console.log(challenge.sid);
}

createChallenge();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

challenge = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("ff483d1ff591898a9942916050d2ca3f")
    .challenges.create(
        details_message="Hi! Mr. John Doe, would you like to sign up?",
        details_fields=[
            {"label": "Action", "value": "Sign up in portal"},
            {"label": "Location", "value": "California"},
        ],
        hidden_details={"ip": "127.0.0.1"},
        auth_payload="12345678",
        factor_sid="YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    )
)

print(challenge.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service.Entity;
using System.Threading.Tasks;
using System.Collections.Generic;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var challenge = await ChallengeResource.CreateAsync(
            detailsMessage: "Hi! Mr. John Doe, would you like to sign up?",
            detailsFields: new List<
                Object> { new Dictionary<string, Object>() { { "label", "Action" }, { "value", "Sign up in portal" } }, new Dictionary<string, Object>() { { "label", "Location" }, { "value", "California" } } },
            hiddenDetails: new Dictionary<string, Object>() { { "ip", "127.0.0.1" } },
            authPayload: "12345678",
            factorSid: "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathIdentity: "ff483d1ff591898a9942916050d2ca3f");

        Console.WriteLine(challenge.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import java.util.Arrays;
import java.util.HashMap;
import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.entity.Challenge;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Challenge challenge = Challenge
                                  .creator("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                                      "ff483d1ff591898a9942916050d2ca3f",
                                      "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                                  .setDetailsMessage("Hi! Mr. John Doe, would you like to sign up?")
                                  .setDetailsFields(Arrays.asList(
                                      new HashMap<String, Object>() {
                                          {
                                              put("label", "Action");
                                              put("value", "Sign up in portal");
                                          }
                                      },
                                      new HashMap<String, Object>() {
                                          {
                                              put("label", "Location");
                                              put("value", "California");
                                          }
                                      }))
                                  .setHiddenDetails(new HashMap<String, Object>() {
                                      {
                                          put("ip", "127.0.0.1");
                                      }
                                  })
                                  .setAuthPayload("12345678")
                                  .create();

        System.out.println(challenge.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &verify.CreateChallengeParams{}
	params.SetDetailsMessage("Hi! Mr. John Doe, would you like to sign up?")
	params.SetDetailsFields([]interface{}{
		map[string]interface{}{
			"label": "Action",
			"value": "Sign up in portal",
		},
		map[string]interface{}{
			"label": "Location",
			"value": "California",
		},
	})
	params.SetHiddenDetails(map[string]interface{}{
		"ip": "127.0.0.1",
	})
	params.SetAuthPayload("12345678")
	params.SetFactorSid("YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

	resp, err := client.VerifyV2.CreateChallenge("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"ff483d1ff591898a9942916050d2ca3f",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$challenge = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->entities("ff483d1ff591898a9942916050d2ca3f")
    ->challenges->create(
        "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", // FactorSid
        [
            "detailsMessage" => "Hi! Mr. John Doe, would you like to sign up?",
            "detailsFields" => [
                [
                    "label" => "Action",
                    "value" => "Sign up in portal",
                ],
                [
                    "label" => "Location",
                    "value" => "California",
                ],
            ],
            "hiddenDetails" => [
                "ip" => "127.0.0.1",
            ],
            "authPayload" => "12345678",
        ]
    );

print $challenge->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

challenge = @client
            .verify
            .v2
            .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .entities('ff483d1ff591898a9942916050d2ca3f')
            .challenges
            .create(
              details_message: 'Hi! Mr. John Doe, would you like to sign up?',
              details_fields: [
                {
                  'label' => 'Action',
                  'value' => 'Sign up in portal'
                },
                {
                  'label' => 'Location',
                  'value' => 'California'
                }
              ],
              hidden_details: {
                'ip' => '127.0.0.1'
              },
              auth_payload: '12345678',
              factor_sid: 'YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
            )

puts challenge.sid
```

```bash
EXCLAMATION_MARK='!'
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:entities:challenges:create \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity ff483d1ff591898a9942916050d2ca3f \
   --details.message "Hi$EXCLAMATION_MARK Mr. John Doe, would you like to sign up?" \
   --details.fields "{\"label\":\"Action\",\"value\":\"Sign up in portal\"}" "{\"label\":\"Location\",\"value\":\"California\"}" \
   --hidden-details "{\"ip\":\"127.0.0.1\"}" \
   --auth-payload 12345678 \
   --factor-sid YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
EXCLAMATION_MARK='!'

HIDDEN_DETAILS_OBJ=$(cat << EOF
{
  "ip": "127.0.0.1"
}
EOF
)
curl -X POST "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges" \
--data-urlencode "Details.Message=Hi$EXCLAMATION_MARK Mr. John Doe, would you like to sign up?" \
--data-urlencode "Details.Fields={\"label\":\"Action\",\"value\":\"Sign up in portal\"}" \
--data-urlencode "Details.Fields={\"label\":\"Location\",\"value\":\"California\"}" \
--data-urlencode "HiddenDetails=$HIDDEN_DETAILS_OBJ" \
--data-urlencode "AuthPayload=12345678" \
--data-urlencode "FactorSid=YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_sid": "YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "ff483d1ff591898a9942916050d2ca3f",
  "factor_sid": "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "date_responded": "2015-07-30T20:00:00Z",
  "expiration_date": "2015-07-30T20:00:00Z",
  "status": "approved",
  "responded_reason": "none",
  "details": {
    "message": "Hi! Mr. John Doe, would you like to sign up?",
    "date": "2020-07-01T12:13:14Z",
    "fields": [
      {
        "label": "Action",
        "value": "Sign up in portal"
      }
    ]
  },
  "hidden_details": {
    "ip": "127.0.0.1"
  },
  "metadata": null,
  "factor_type": "totp",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "notifications": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications"
  }
}
```

## Fetch a Challenge resource

`GET https://verify.twilio.com/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true},{"name":"Identity","in":"path","description":"Customer unique identity for the Entity owner of the Challenges. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true},{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Challenge.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YC[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch a Challenge

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchChallenge() {
  const challenge = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(challenge.sid);
}

fetchChallenge();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

challenge = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(challenge.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service.Entity;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var challenge = await ChallengeResource.FetchAsync(
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathIdentity: "Identity",
            pathSid: "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(challenge.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.entity.Challenge;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Challenge challenge =
            Challenge.fetcher("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .fetch();

        System.out.println(challenge.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.VerifyV2.FetchChallenge("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"Identity",
		"YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$challenge = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->entities("Identity")
    ->challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $challenge->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

challenge = @client
            .verify
            .v2
            .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .entities('Identity')
            .challenges('YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .fetch

puts challenge.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:entities:challenges:fetch \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity \
   --sid YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/Identity/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_sid": "YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "Identity",
  "factor_sid": "YFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "date_responded": "2015-07-30T20:00:00Z",
  "expiration_date": "2015-07-30T20:00:00Z",
  "status": "approved",
  "responded_reason": "none",
  "details": {
    "message": "Hi! Mr. John Doe, would you like to sign up?",
    "date": "2020-07-01T12:13:14Z",
    "fields": [
      {
        "label": "Action",
        "value": "Sign up in portal"
      }
    ]
  },
  "hidden_details": {
    "ip": "172.168.1.234"
  },
  "metadata": {
    "os": "Android"
  },
  "factor_type": "push",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "notifications": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications"
  }
}
```

## Read multiple Challenge resources

`GET https://verify.twilio.com/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true},{"name":"Identity","in":"path","description":"Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true}]
```

### Query parameters

```json
[{"name":"FactorSid","in":"query","description":"The unique SID identifier of the Factor.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YF[0-9a-fA-F]{32}$"}},{"name":"Status","in":"query","description":"The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`.","schema":{"type":"string","enum":["pending","expired","approved","denied"],"description":"The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.","refName":"challenge_enum_challenge_statuses","modelName":"challenge_enum_challenge_statuses"}},{"name":"Order","in":"query","description":"The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`.","schema":{"type":"string","enum":["asc","desc"],"refName":"challenge_enum_list_orders","modelName":"challenge_enum_list_orders"}},{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 1000.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":1000}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

List multiple Challenges

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listChallenge() {
  const challenges = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges.list({ limit: 20 });

  challenges.forEach((c) => console.log(c.sid));
}

listChallenge();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

challenges = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges.list(limit=20)
)

for record in challenges:
    print(record.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service.Entity;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var challenges = await ChallengeResource.ReadAsync(
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathIdentity: "Identity",
            limit: 20);

        foreach (var record in challenges) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.entity.Challenge;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Challenge> challenges =
            Challenge.reader("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity").limit(20).read();

        for (Challenge record : challenges) {
            System.out.println(record.getSid());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &verify.ListChallengeParams{}
	params.SetLimit(20)

	resp, err := client.VerifyV2.ListChallenge("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"Identity",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Sid != nil {
				fmt.Println(*resp[record].Sid)
			} else {
				fmt.Println(resp[record].Sid)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$challenges = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->entities("Identity")
    ->challenges->read([], 20);

foreach ($challenges as $record) {
    print $record->sid;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

challenges = @client
             .verify
             .v2
             .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
             .entities('Identity')
             .challenges
             .list(limit: 20)

challenges.each do |record|
   puts record.sid
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:entities:challenges:list \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity
```

```bash
curl -X GET "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/Identity/Challenges?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "challenges": [],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "challenges"
  }
}
```

## Update a Challenge resource

`POST https://verify.twilio.com/v2/Services/{ServiceSid}/Entities/{Identity}/Challenges/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true},{"name":"Identity","in":"path","description":"Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user's UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.","schema":{"type":"string"},"x-twilio":{"pii":{"handling":"standard","deleteSla":30}},"required":true},{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Challenge.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YC[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateChallengeRequest","properties":{"AuthPayload":{"type":"string","description":"The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length"},"Metadata":{"description":"Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}}}},"examples":{"verifyPush":{"value":{"lang":"json","value":"{\n  \"AuthPayload\": \"123456\",\n  \"Metadata\": \"{\\\"os\\\": \\\"Android\\\"}\"\n}","meta":"","code":"{\n  \"AuthPayload\": \"123456\",\n  \"Metadata\": \"{\\\"os\\\": \\\"Android\\\"}\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"AuthPayload\"","#7EE787"],[":","#C9D1D9"]," ",["\"123456\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Metadata\"","#7EE787"],[":","#C9D1D9"]," ",["\"{","#A5D6FF"],["\\\"","#79C0FF"],["os","#A5D6FF"],["\\\"","#79C0FF"],[":","#A5D6FF"]," ",["\\\"","#79C0FF"],["Android","#A5D6FF"],["\\\"","#79C0FF"],["}\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}},"verifyTotp":{"value":{"lang":"json","value":"{\n  \"AuthPayload\": \"123456\"\n}","meta":"","code":"{\n  \"AuthPayload\": \"123456\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"AuthPayload\"","#7EE787"],[":","#C9D1D9"]," ",["\"123456\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a Challenge

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateChallenge() {
  const challenge = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update({ authPayload: "AuthPayload" });

  console.log(challenge.sid);
}

updateChallenge();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

challenge = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .entities("Identity")
    .challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .update(auth_payload="AuthPayload")
)

print(challenge.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service.Entity;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var challenge = await ChallengeResource.UpdateAsync(
            authPayload: "AuthPayload",
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathIdentity: "Identity",
            pathSid: "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(challenge.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.entity.Challenge;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Challenge challenge =
            Challenge.updater("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .setAuthPayload("AuthPayload")
                .update();

        System.out.println(challenge.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &verify.UpdateChallengeParams{}
	params.SetAuthPayload("AuthPayload")

	resp, err := client.VerifyV2.UpdateChallenge("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"Identity",
		"YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$challenge = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->entities("Identity")
    ->challenges("YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->update(["authPayload" => "AuthPayload"]);

print $challenge->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

challenge = @client
            .verify
            .v2
            .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .entities('Identity')
            .challenges('YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
            .update(auth_payload: 'AuthPayload')

puts challenge.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:entities:challenges:update \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity \
   --sid YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --auth-payload AuthPayload
```

```bash
curl -X POST "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/Identity/Challenges/YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--data-urlencode "AuthPayload=AuthPayload" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "YCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_sid": "YEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "identity": "Identity",
  "factor_sid": "YF03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "date_responded": "2015-07-30T20:00:00Z",
  "expiration_date": "2015-07-30T20:00:00Z",
  "status": "approved",
  "responded_reason": "none",
  "details": {
    "message": "Hi! Mr. John Doe, would you like to sign up?",
    "date": "2020-07-01T12:13:14Z",
    "fields": [
      {
        "label": "Action",
        "value": "Sign up in portal"
      }
    ]
  },
  "hidden_details": {
    "ip": "172.168.1.234"
  },
  "metadata": {
    "os": "Android"
  },
  "factor_type": "push",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "notifications": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Entities/ff483d1ff591898a9942916050d2ca3f/Challenges/YC03aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications"
  }
}
```
