---
title: "Check a code by destination"
description: "Checks a code against the most recent verification sent to `destination`. Checking by ID is\nrecommended instead: if you use this endpoint, make sure two users cannot verify the same\nnumber at once and that the number cannot change mid-flow.\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-by`

Checks a code against the most recent verification sent to `destination`. Checking by ID is
recommended instead: if you use this endpoint, make sure two users cannot verify the same
number at once and that the number cannot change mid-flow.

## Authentication

- `basicAuth`, http, header `Authorization`

## Request body

_Required._

- `destination` (`checkVerificationByDestination.destination`; string, required) — The number being verified.
- `code` (`checkVerificationByDestination.code`; integer, required) — Code entered by the user. Must be numeric.

## Example request

```json
{
  "destination": "+61412345678",
  "code": 482913
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://app.messageport.com.au/api/v3/verify/verify-by \
  --header 'Authorization: Basic <credentials>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "destination": "+61412345678",
  "code": 482913
}
'
```

### TypeScript

```typescript
const url = 'https://app.messageport.com.au/api/v3/verify/verify-by';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Basic <credentials>'},
  body: JSON.stringify({destination: '+61412345678', 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/verify-by"

payload = {
    "destination": "+61412345678",
    "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` (`checkVerificationByDestination.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` (`checkVerificationByDestination.response.200.data.id`; string, optional)
    - format `uuid`
  - `status` (`checkVerificationByDestination.response.200.data.status`; string, optional)
    - one of `"created"`, `"sent"`, `"expired"`, `"failed"`, `"verified"`, `"cancelled"`
  - `type` (`checkVerificationByDestination.response.200.data.type`; string, optional)
    - one of `"sms"`, `"email"`
  - `destination` (`checkVerificationByDestination.response.200.data.destination`; string, optional)
  - `source` (`checkVerificationByDestination.response.200.data.source`; string, optional)
  - `metadata` (`checkVerificationByDestination.response.200.data.metadata`; object | null, optional)
  - `template` (`checkVerificationByDestination.response.200.data.template`; string, optional)
  - `expires_at` (`checkVerificationByDestination.response.200.data.expires_at`; string, optional)
    - format `date-time`
  - `created_at` (`checkVerificationByDestination.response.200.data.created_at`; string, optional)
    - format `date-time`
- `verify_success` (`checkVerificationByDestination.response.200.verify_success`; boolean, optional) — Whether the code was accepted.
- `verify_error` (`checkVerificationByDestination.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` (`checkVerificationByDestination.response.401.message`; string, required)

### 404

No verification was found for this destination.

#### Example

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

- `message` (`checkVerificationByDestination.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` (`checkVerificationByDestination.response.422.message`; string, optional)
- `errors` (`checkVerificationByDestination.response.422.errors`; map<array<string>>, optional)


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