# Get regulatory requirements

> Get the regulatory information needed to buy a phone number, for one specific number or for a country and number type. Prefer phoneNumber: the response is then exactly the list the purchase of that number validates against. Pass each requirementTypes[].id back as requirementType in regulatoryRequirements on POST /v1/phone-numbers.

`GET https://api.zavu.dev/v1/phone-numbers/requirements`

Get the regulatory information needed to buy a phone number, for one specific number or for a country and number type. Prefer `phoneNumber`: the response is then exactly the list the purchase of that number validates against. Pass each `requirementTypes[].id` back as `requirementType` in `regulatoryRequirements` on `POST /v1/phone-numbers`.

For `phoneNumber`, the requirements of that exact number are returned. When they cannot be resolved for the number itself, the list for its country and `type` is returned instead, and the purchase uses the same list. An empty `items` array means the number needs no regulatory information. If the requirements cannot be retrieved at all, the response is `502 requirements_unavailable`, never an empty list.

URL-encode the `+` of `phoneNumber` as `%2B`. An unencoded `+` is also accepted.

## Parameters

- `countryCode` (query, string): Two-letter ISO country code. Required unless `phoneNumber` is given.
- `type` (query, string): Type of phone number (local, national, mobile, tollFree). Defaults to `local`. With `phoneNumber`, used only when the number's own requirements cannot be resolved and the country list is returned. One of: `local`, `national`, `tollFree`, `mobile`.
- `phoneNumber` (query, string): E.164 number from `GET /v1/phone-numbers/available`, with `+` encoded as `%2B`. Returns the requirements the purchase of that number checks. Takes precedence over `countryCode`.

## Responses

### 200

Requirements for the number, or for the country and type.

- `items` (object[], required)
  - `id` (string, required)
  - `countryCode` (string, required)
  - `phoneNumberType` (string, required)
  - `action` (string, required)
  - `requirementTypes` (object[], required)
    - `id` (string, required): Send this as `requirementType` in `regulatoryRequirements` when purchasing.
    - `name` (string, required)
    - `description` (string, required)
    - `type` (string, required): Type of requirement field. One of: `textual`, `address`, `document`, `action`.
    - `example` (string, nullable)
    - `acceptanceCriteria` (object): Acceptance criteria for a requirement.
      - `minLength` (integer, nullable)
      - `maxLength` (integer, nullable)
      - `allowedValues` (string[], nullable)
      - `regexPattern` (string, nullable)

### 400

Neither `countryCode` nor `phoneNumber` was given, one is malformed, or the requirements cannot be looked up for this input (`invalid_request`).

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 502

The requirements could not be retrieved right now. Retry; do not treat this as "no requirements".

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X GET "https://api.zavu.dev/v1/phone-numbers/requirements?countryCode=DE&phoneNumber=%2B4930123456" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.phoneNumbers.requirements({
  countryCode: "DE",
  phoneNumber: "+4930123456",
});

console.log(result);
```
