# Setup your account

> Create your account, mint an API key in the right environment, and wire it into your SDK.

Every call to the Wajub API is authenticated by a key, and a key belongs to one account and one
environment. This page takes you from no account at all to an SDK that authenticates, which is the
state the [Quickstart](https://docs.wajub.com/getting-started/quickstart) assumes you are already in.

## 1. Create your account

Sign up at &#x2A;*[dashboard.wajub.com](https://dashboard.wajub.com)** with your name, email and a
password, then confirm the email we send you. Nothing is payable at this stage, a new account lands
on the free **Pay as you go** plan.

Your user account comes first and your business second. Right after confirming your email, the
Dashboard asks you to create your first merchant account, on a screen titled **Tell us about your
Business**:

| Field          | Required | What it is for                                                                                             |
| -------------- | -------- | ---------------------------------------------------------------------------------------------------------- |
| Merchant Name  | Yes      | Your company, project or application name.                                                                 |
| Business Email | No       | Printed on the invoices and emails your customers receive. Your own email is used when you leave it empty. |
| Business Phone | No       | Shown to your customers next to that email, so they can reach you.                                         |

You are the owner of that account. The Dashboard stays on this screen until it exists, and you can
create other merchant accounts later from the same user.

Your team is created in **sandbox**, and it stays there until your business verification is
approved. Nothing you do now can move real money, which is the point: build and break things freely
before [activation](https://docs.wajub.com/getting-started/account-activation) opens production.

The Dashboard home shows a setup checklist tailored to what you said you were building. It tracks
the same milestones this page covers, so you can follow either one.

## 2. Select the environment before you mint a key

This is the step people skip. A key is minted for whichever environment the Dashboard is currently
showing. Flip the environment switch to sandbox or to live **first**, then create the key. Create it in the wrong environment and it will authenticate
fine while returning data from an environment you did not mean to touch.

Live stays unavailable until your account is verified, so until then every key you create is a
`_test` key whatever you do.

Switching environment is itself a permission. The account owner can always do it, other members need
a role that may do it, **Administrator** or **Developer** by default, and a member with the
**Sandbox User** role can never switch to live.

## 3. Create your first API key

Open **Settings → Developers → API keys** and create a key. You pick
the type, and the prefix follows from that choice and from the environment you selected in step 2.

| Type       | Sandbox prefix | Production prefix | Use it for                                                                    |
| ---------- | -------------- | ----------------- | ----------------------------------------------------------------------------- |
| Public     | `pk_test.`     | `pk.`             | Browser and mobile code, to create a payment. Holding it is not a permission. |
| Private    | `sk_test.`     | `sk.`             | Your server. Full access to the API.                                          |
| Restricted | `rk_test.`     | `rk.`             | Your server, limited to the scopes you grant.                                 |

Start with a private key. A restricted key is worth the extra step once you know which endpoints
you actually call, and [Environments & API keys](https://docs.wajub.com/getting-started/environments) covers the scopes,
the IP allow-list and the expiry date you can attach to any of them.

> [!CAUTION]
> **Copy the value right away**
>
> The full value appears in the banner right after creation. Copy it into your secrets manager
> before you leave the page. The key list then shows only its first characters. You can display a
> private or restricted key again with **Reveal**, which asks for a security verification code, is
> rate limited and is recorded in the audit log. A public key stays copyable from the list.

If you have the [CLI](https://docs.wajub.com/developer-tools/cli/installation) installed, `wajub login` does this for
you: it pairs the terminal with your account through the browser, and the owner, an
Administrator or a Developer (a Sandbox User too, for a sandbox key) approves the request and
picks the environment, Sandbox unless they choose Live. The CLI stores the key in a local profile.
That key expires after 90 days, and `wajub login` gives you a new one. The WordPress plugin's
**Connect with Wajub** asks for a key the same way, and its key lasts 90 days unless the approver
picks **No expiry**. Each key a pairing creates sends the owner and every Administrator an email.

## 4. Put the key in your environment

Keys belong in the environment, never in the code and never in the repository. Create a `.env` file
at the root of your project and keep it out of git.

```bash title=".env"
WAJUB_API_KEY=sk_test.xxxxxxxxxxxxxxxx…
WAJUB_WEBHOOK_SECRET=whsec_test_xxxxxxxxxxxxxxxx
```

`WAJUB_API_KEY` is the name every SDK recognises, so use it rather than inventing your own.
`WAJUB_WEBHOOK_SECRET` is the signing secret of a webhook endpoint, a different credential
entirely, and step 6 is where you get one.

## 5. Point the SDK at the key

Two of the SDKs read `WAJUB_API_KEY` from the environment on their own. Python and Go construct a
working client from an empty configuration, so the snippets below pass nothing.

Node and PHP do not read the environment, they raise on an empty configuration, so you hand them
the value yourself.

**Authenticate the SDK**

```javascript
import { Wajub } from '@wajub/node';

const wajub = new Wajub({ apiKey: process.env.WAJUB_API_KEY });
```

```python
from wajub import Wajub

wajub = Wajub()
```

```php
<?php

use Wajub\Wajub;

$wajub = new Wajub([
  'api_key' => getenv('WAJUB_API_KEY'),
]);
```

```go
package main

import (
"log"

"github.com/wajubhq/wajub-go"
)

func main() {
client, err := wajub.New(wajub.Config{})

if err != nil {
	log.Fatal(err)
}

_ = client
}
```

Whichever SDK you use, all four read `WAJUB_WEBHOOK_SECRET` on their own for signature
verification, so once that variable is set you never pass the secret explicitly.

## 6. Register a webhook endpoint

A payment confirms asynchronously, so your server learns the outcome from a webhook rather than
from the response to the call that created it. Register the endpoint now, while you are in the
Dashboard, so the [Quickstart](https://docs.wajub.com/getting-started/quickstart) has somewhere to deliver to.

Open **Konsole → Webhooks → Endpoints**, add your URL, and copy the signing secret shown on the
endpoint. It looks like `whsec_test_` followed by 32 characters in sandbox, and `whsec_` followed
by 32 characters in production.

That secret is per endpoint and per environment. Registering the same URL again in live gives you a
different secret, which is why going to production means copying a new one rather than reusing what
you have. Use it to [verify every incoming
signature](https://docs.wajub.com/developer-tools/webhooks/signature-verification) before you trust a payload.

## 7. Roll a key that leaked

Rolling replaces the value in place. The name, the scopes and the IP allow-list survive, the old
value stops authenticating the moment you confirm, and there is no grace window where both work. So
have the new value ready to deploy before you click, or you take an outage between the roll and the
release.

Because it is destructive, rolling asks for a security verification code if you have not entered
one recently. Deleting a key asks the same.

## 8. Who on your team can do this

API keys are visible only to the account owner and to members whose role lets them manage API keys:
**Administrator**, **Developer** and **Sandbox User**. Any other member still finds
**Settings → Developers → API keys** in the menu, but the page answers "You do not have the required
permission to perform this action.": ask an admin to change your role.
The dashboard guide's [roles table](https://docs.wajub.com/dashboard#roles) lists what each role can do.

## 9. When production opens

Verified accounts get live keys the same way, by switching the environment and creating a key. Live
keys are separate objects, a sandbox key is never promoted. Plan on swapping the key, the webhook
URL and its new signing secret together, and walk the [Going Live
checklist](https://docs.wajub.com/getting-started/going-live) before you do.

- [Quickstart](https://docs.wajub.com/getting-started/quickstart): Your first payment, with the key you just created.
- [Environments & API keys](https://docs.wajub.com/getting-started/environments): Key formats, scopes, IP allow-lists, expiry.
- [Account activation & KYC](https://docs.wajub.com/getting-started/account-activation): The documents that unlock production.
- [Security best practices](https://docs.wajub.com/best-practices/security): Storing, rotating and scoping credentials.
