# KSA v2: Sign up

Create an account in the Complyance test environment to use the KSA ZATCA API v2 (onboarding, reporting and clearance). This page documents API v2, a legacy version.

> **Legacy API v2**
>
> This page documents API v2, which is no longer developed. New integrations should use the current API: see [Unify](https://docs.complyance.io/api-reference/unify/) and [Saudi Arabia](https://docs.complyance.io/countries/sa/).

Use this API to create an account in the Complyance test environment. The account lets you use the ZATCA APIs: onboarding, reporting and clearance.

Send every required parameter in the format shown below.

## Endpoint

```http
POST https://<your-v2-api-host>/api/v1/proto/signUp
```

Use the v2 API host you were given when your account was set up. If you no longer have it, contact <support@complyance.io>.

## Examples

**cURL**

```bash title="Sign up"
curl -X POST https://<your-v2-api-host>/api/v1/proto/signUp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"email": "finance@acme.example", "password": "Example@123"}'
```

**JavaScript**

```javascript title="Sign up"
const inputBody = JSON.stringify({
  email: 'finance@acme.example',
  password: 'Example@123'
});
const headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
};

fetch('https://<your-v2-api-host>/api/v1/proto/signUp', {
  method: 'POST',
  body: inputBody,
  headers: headers
})
  .then(function (res) {
    return res.json();
  })
  .then(function (body) {
    console.log(body);
  });
```

**Ruby**

```ruby title="Sign up"
require 'rest-client'
require 'json'

headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json'
}

body = {
  email: 'finance@acme.example',
  password: 'Example@123'
}.to_json

result = RestClient.post 'https://<your-v2-api-host>/api/v1/proto/signUp', body, headers

p JSON.parse(result)
```

**Python**

```python title="Sign up"
import requests

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}
body = {
  'email': 'finance@acme.example',
  'password': 'Example@123'
}

r = requests.post('https://<your-v2-api-host>/api/v1/proto/signUp', json=body, headers=headers)

print(r.json())
```

**PHP**

```php title="Sign up"
<?php

require 'vendor/autoload.php';

$headers = array(
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// The request body.
$request_body = array(
    'email' => 'finance@acme.example',
    'password' => 'Example@123',
);

try {
    $response = $client->request('POST', 'https://<your-v2-api-host>/api/v1/proto/signUp', array(
        'headers' => $headers,
        'json' => $request_body,
    ));
    print_r($response->getBody()->getContents());
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // Handle the exception or API errors.
    print_r($e->getMessage());
}
```

**Java**

```java title="Sign up"
URL obj = new URL("https://<your-v2-api-host>/api/v1/proto/signUp");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String body = "{\"email\": \"finance@acme.example\", \"password\": \"Example@123\"}";
try (OutputStream os = con.getOutputStream()) {
    os.write(body.getBytes(StandardCharsets.UTF_8));
}
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

## Request parameters

| Parameter | Required | Type | Description | Example |
| - | - | - | - | - |
| `email` | Yes | string | The email address for the account you want to create. | `finance@acme.example` |
| `password` | Yes | string | The password for your Complyance test account. It must contain at least one capital letter, one special character and one number. | `Example@123` |

```json title="Request body"
{
  "email": "finance@acme.example",
  "password": "Example@123"
}
```

## Response parameters

| Parameter | Type | Description | Example |
| - | - | - | - |
| `refreshToken` | string | A long-lived token, valid for one year. Store it securely: you use it to get a new access token every 24 hours. | `eyJjdHkiOiJKV1QifQ.example-refresh-token.signature` |

```json title="Response"
{
  "refreshToken": "eyJjdHkiOiJKV1QifQ.example-refresh-token.signature"
}
```

## Next step

[Sign in](https://docs.complyance.io/legacy/v2/ksa/signin/) with the refresh token to get an access token.

Source: https://docs.complyance.io/legacy/v2/ksa/signup/
