# Quick Start

## Get your API keys

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can generate an API key on <https://pay.imal.dev/register.html>

## Make your first invoice

To make your first request, send an authenticated request to the createTransaction endpoint. This will create a transaction.

## Create a new transaction

<mark style="color:green;">`POST`</mark> `https://pay.imal.dev/api/createTransaction`

Creates a new transaction.

#### Request Body

| Name                                          | Type   | Description                                                                                            |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| key<mark style="color:red;">\*</mark>         | string | Your merchant API key.                                                                                 |
| description<mark style="color:red;">\*</mark> | string | Description of the transaction (eg. Invoice #63729)                                                    |
| tokenid<mark style="color:red;">\*</mark>     | string | tti\_ of the vite token used for the transaction                                                       |
| amount<mark style="color:red;">\*</mark>      | String | RAW Amount of the token used for the transaction                                                       |
| memoprefix                                    | String | Prefix for the memo used in the transaction (eg. "gifts" would result in something like "gifts823729") |
| destination<mark style="color:red;">\*</mark> | String | Address the funds should be sent to.                                                                   |
| redirecturl<mark style="color:red;">\*</mark> | String | "Back to merchant" URL                                                                                 |

{% tabs %}
{% tab title="200 Transaction successfully created" %}

```javascript
{
  "code": 1,
  "id": "927192719",
  "expires": "192019281",
  "url": "https://pay.imal.dev/pay/82837829"
}
```

{% endtab %}

{% tab title="400: Bad Request memoPrefix too long" %}

```javascript
{
  "code": 2
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid TokenID" %}

```javascript
{
  "code": 3
}
```

{% endtab %}

{% tab title="400: Bad Request Incorrect destination address" %}

```javascript
{
  "code": 4
}
```

{% endtab %}

{% tab title="400: Bad Request Amount is NaN (Not a number)" %}

```javascript
{
  "code": 5
}
```

{% endtab %}

{% tab title="400: Bad Request Redirect URL invalid or empty." %}

```javascript
{
  "code": 7
}
```

{% endtab %}

{% tab title="400: Bad Request Description too long (max. 75 characters)" %}

```javascript
{
  "code": 6
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid API Key" %}

```javascript
{
  "code": 8
}
```

{% endtab %}

{% tab title="500: Internal Server Error SQL/Server Error" %}

```javascript
{
  "code": 500
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using `curl`:

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

```
curl --location --request POST 'https://pay.imal.dev/api/createTransaction' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "AFJIOAs98ksks9",
    "description": "Invoice #92828",
    "tokenid": "tti_5649544520544f4b454e6e40",
    "amount": "100000000000000000000",
    "memoprefix": "gifts",
    "destination": "vite_2ff6ffebcf03638b20072c9b40a49778e894420ddf58e40df5",
    "redirecturl": "https://example.com"
}'
```

{% endtab %}
{% endtabs %}
