> For the complete documentation index, see [llms.txt](https://photon-commerce.gitbook.io/photon-commerce-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://photon-commerce.gitbook.io/photon-commerce-api/master/register-a-new-account.md).

# Register a new account

Registering a new account with email and password can provide you with a set of API credentials.

## Register

<mark style="color:green;">`POST`</mark> `https://api.photoncommerce.com/api/v4/register`

Register using your email address and a password to receive a Client ID, Client Secret and an API Key

#### Headers

| Name         | Type   | Description               |
| ------------ | ------ | ------------------------- |
| Accept       | string | Set to "application/json" |
| Content-Type | string | Set to "application/json" |

#### Request Body

| Name     | Type   | Description                                                                                                  |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------ |
| password | string | <p>Passwords must be atleast 10 characters<br>long, must contain atleast 1 digit and 1 special character</p> |
| email    | string | your email address                                                                                           |

{% tabs %}
{% tab title="200 " %}

```
{"client_id":"<your client ID>","api_key":"<your API Key>","secret_key":"<your client secret>","username":"<your email>","password":"<your password>"}
```

{% endtab %}

{% tab title="403 " %}

```
{"registration":"failed","reason":"username already exists"}
```

{% endtab %}
{% endtabs %}

\*\*\*Note: When the registration succeeds, you will receive an email containing a verification link. Click on it and you're good to go! Before verifying your email, you will not be able to use these credentials.

{% tabs %}
{% tab title="cURL" %}

```
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"email": "<your-email>", "password": "<your-password>"}'  "https://api.photoncommerce.com/api/v4/register" 
```

{% endtab %}

{% tab title="Python" %}

```
import requests

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

payload = {
    'email':'your-email-address',
    'password':'must-be-secure-and-valid-1'
}

response = requests.post('https://api.photoncommerce.com/api/v4/register', headers=headers, json=payload)
r = response.json()
try:
    for key in r:
        print(f'{key}: {r[key]}')
except:
    print(f'Registration failed, response from API: {r}')
    
```

{% endtab %}

{% tab title="NodeJS" %}

```
var request = require('request');

var headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
};

var dataString = '{"email": "<your-email>", "password": "<your-password>"}';

var options = {
    url: 'https://api.photoncommerce.com/api/v4/register',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
```

{% endtab %}

{% tab title="Java" %}

```
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://api.photoncommerce.com/api/v4/register");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("POST");

		httpConn.setRequestProperty("Content-Type", "application/json");
		httpConn.setRequestProperty("Accept", "application/json");

		httpConn.setDoOutput(true);
		OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
		writer.write("{\"email\": \"<your-email>\", \"password\": \"<your-password>\"}");
		writer.flush();
		writer.close();
		httpConn.getOutputStream().close();

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}
```

{% endtab %}
{% endtabs %}
