---
title: "Check a code"
description: "Checks the code the user entered against a verification. A wrong, expired or already-used\ncode still returns `200`: check `verify_success`, and `verify_error` for the reason.\n"
version: "v2"
---

> Documentation Index
> Fetch the complete documentation index at: https://dev.messageport.com.au/llms.txt
> Use this file to discover all available pages before exploring further.

Path: MessagePort API › Verify

`POST /v3/verify/{verify}/verify`

Checks the code the user entered against a verification. A wrong, expired or already-used
code still returns `200`: check `verify_success`, and `verify_error` for the reason.

## Authentication

- `basicAuth`, http, header `Authorization`

## Path parameters

- `verify` (`checkVerification.path.verify`; string, required) — Verification ID returned when it was created.
  - format `uuid`

## Request body

_Required._

- `code` (`checkVerification.code`; string, required) — Code entered by the user.

## Example request

```json
{
  "code": "482913"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://app.messageport.com.au/api/v3/verify/cb4d9527-1d3a-4def-85ba-f1fec9489c4f/verify \
  --header 'Authorization: Basic <credentials>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "482913"
}
'
```

### TypeScript

```typescript
const url = 'https://app.messageport.com.au/api/v3/verify/cb4d9527-1d3a-4def-85ba-f1fec9489c4f/verify';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Basic <credentials>'},
  body: JSON.stringify({code: '482913'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://app.messageport.com.au/api/v3/verify/cb4d9527-1d3a-4def-85ba-f1fec9489c4f/verify"

payload = { "code": "482913" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic <credentials>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The verification and the result of the check. A failed check still returns `200`;
use `verify_success`.

#### Example

```json
{
  "data": {
    "id": "cb4d9527-1d3a-4def-85ba-f1fec9489c4f",
    "status": "verified",
    "type": "sms",
    "destination": "+61412345678",
    "source": "SHARED_NUMBER",
    "metadata": null,
    "template": "Your verification code is %code%",
    "expires_at": "2024-03-11T02:19:07.000000Z",
    "created_at": "2024-03-11T02:14:07.000000Z"
  },
  "verify_success": true,
  "verify_error": null
}
```

- `data` (`checkVerification.response.200.data`; object, optional)
  - example `{"id":"cb4d9527-1d3a-4def-85ba-f1fec9489c4f","status":"sent","type":"sms","destination":"+61412345678","source":"SHARED_NUMBER","metadata":{"action":"login"},"template":"Your verification code is %code%","expires_at":"2024-03-11T02:19:07.000000Z","created_at":"2024-03-11T02:14:07.000000Z"}`
  - `id` (`checkVerification.response.200.data.id`; string, optional)
    - format `uuid`
  - `status` (`checkVerification.response.200.data.status`; string, optional)
    - one of `"created"`, `"sent"`, `"expired"`, `"failed"`, `"verified"`, `"cancelled"`
  - `type` (`checkVerification.response.200.data.type`; string, optional)
    - one of `"sms"`, `"email"`
  - `destination` (`checkVerification.response.200.data.destination`; string, optional)
  - `source` (`checkVerification.response.200.data.source`; string, optional)
  - `metadata` (`checkVerification.response.200.data.metadata`; object | null, optional)
  - `template` (`checkVerification.response.200.data.template`; string, optional)
  - `expires_at` (`checkVerification.response.200.data.expires_at`; string, optional)
    - format `date-time`
  - `created_at` (`checkVerification.response.200.data.created_at`; string, optional)
    - format `date-time`
- `verify_success` (`checkVerification.response.200.verify_success`; boolean, optional) — Whether the code was accepted.
- `verify_error` (`checkVerification.response.200.verify_error`; string | null, optional) — Why the check failed, for example `Provided code does not match verify`, `Verify expired before check request`, `Verify cancelled before check request` or `Verify already used`.

### 401

Missing, malformed or invalid API credentials.

#### Example

```json
{
  "message": "Unauthenticated."
}
```

- `message` (`checkVerification.response.401.message`; string, required)

### 403

The resource exists but does not belong to you, or you lack permission.

#### Example

```json
{
  "message": "This action is unauthorized."
}
```

- `message` (`checkVerification.response.403.message`; string, required)

### 404

The resource does not exist.

#### Example

```json
{
  "message": "Not Found"
}
```

- `message` (`checkVerification.response.404.message`; string, required)

### 422

The request failed validation. `errors` lists the messages for each invalid field.

#### Example

```json
{
  "message": "The messages field is required.",
  "errors": {
    "messages": [
      "The messages field is required."
    ]
  }
}
```

- `message` (`checkVerification.response.422.message`; string, optional)
- `errors` (`checkVerification.response.422.errors`; map<array<string>>, optional)


Source: https://dev.messageport.com.au/api/verify/check/index.md
