Skip to content

Confirm a verification code

Confirm a previously issued verification using a combination of the verification id and the user-supplied verification code.

Request

POSThttps://api.verifyapi.dev/confirm

Body

json
{
    "id": "6603443f241aa2b2299003b6",
    "code": "123456"
}

Properties


id string required

Unique identifier of a previously issued verification. This value should have been stored when requesting a confirmation.

Example: 6603443f241aa2b2299003b6


code string required

User-supplied verification code that was sent to the verification destination. This will come in the form of a digit, alphabet or alphanumeric code which gets delivered to the end-user via SMS or a voice call.

Example: 123456

Examples

bash
curl --request POST \
  --url https://api.verifyapi.dev/confirm \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{ 
    "id": "6603443f241aa2b2299003b6", 
    "code": "123456" 
}'
csharp
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://api.verifyapi.dev/confirm"),
    Headers =
    {
        { "Authorization", "Bearer YOUR_API_KEY" },
    },
    Content = new StringContent("{ \"id\":\"6603443f241aa2b2299003b6\", \"code\":\"123456\" }")
    {
        Headers =
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.verifyapi.dev/confirm"

	payload := strings.NewReader("{ \"id\":\"6603443f241aa2b2299003b6\", \"code\":\"123456\" }")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
java
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.verifyapi.dev/confirm"))
    .header("Content-Type", "application/json")
    .header("Authorization", "Bearer YOUR_API_KEY")
    .method("POST", HttpRequest.BodyPublishers.ofString("{ \"id\":\"6603443f241aa2b2299003b6\", \"code\":\"123456\" }"))
    .build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
javascript
fetch('https://api.verifyapi.dev/confirm', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    id: '6603443f241aa2b2299003b6',
    code: '123456'
  })
})
javascript
const axios = require('axios').default;
const options = {
  method: 'POST',
  url: 'https://api.verifyapi.dev/confirm',
  headers: {
    'Content-Type': 'application/json', 
    Authorization: 'Bearer YOUR_API_KEY' 
  },
  data: {
    id: '6603443f241aa2b2299003b6',
    code: '123456'
  }
};

try {
  const { data } = await axios.request(options);
  console.log(data);
} catch (error) {
  console.error(error);
}
php
$request = new HttpRequest();
$request->setUrl('https://api.verifyapi.dev/confirm');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders([
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer YOUR_API_KEY'
]);

$request->setContentType('application/json');
$request->setBody(json_encode([
  'id' => '6603443f241aa2b2299003b6',
  'code' => '123456'
]));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
python
import http.client

conn = http.client.HTTPSConnection("api.verifyapi.dev")

payload = "{ \"id\":\"6603443f241aa2b2299003b6\", \"code\":\"123456\" }"

headers = {
    'Content-Type': "application/json",
    'Authorization': "Bearer YOUR_API_KEY"
}

conn.request("POST", "/confirm", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
ruby
require 'uri'
require 'net/http'

url = URI("https://api.verifyapi.dev/confirm")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer YOUR_API_KEY'
request.body = "{ \"id\":\"6603443f241aa2b2299003b6\", \"code\":\"123456\" }"


response = http.request(request)
puts response.read_body

Response

HTTP 200 OK Verification has been matched, and the supplied code matches the originally issued code. The verification is successful and the customer's identity can be validated.


HTTP 400 Bad Request The payload is invalid or missing required fields. Additional information on which field is invalid will be returned as part of the JSON response.


HTTP 403 Forbidden The user-supplied code does not match the originally issued code on the associated verification.


HTTP 404 Not Found The verification id cannot be found.


HTTP 409 Conflict The verification has already successfully been confirmed.