---
id: quickstart
title: "Quickstart"
sidebar_label: Quickstart
hide_title: true
description: "Management API - Make your first call in five minutes"
---

import Ingress from '../../../src/components/ingress/ingress.react';

<Ingress title="Quickstart">
    Go from credentials to your first response in about five minutes. You will create an API key,
    exchange it for an access token, and read an order from the test environment.
</Ingress>

## Before you start

You need:

- Access to the test Merchant Hub at [merchanthub.aks.uat.walleydev.com](https://merchanthub.aks.uat.walleydev.com) with permission to manage access
- An order id from the test environment. Pick one in Merchant Hub, or take the `OrderId` from a [`walley:order:created` webhook](/docs/webhooks/orders)
- A terminal with `curl`

Every example below points at the test environment. Production has its own Merchant Hub, hostnames,
and scope, and keys from one environment do not work in the other. See
[Merchant Hub environments](/docs/merchanthub/environments) and
[Endpoints for test and production](/docs/manage/getting-started/endpoints).

## 1. Create an API key

In the test Merchant Hub, open the menu under your name in the top right and select
**Manage Organization**. Select **Create new**, then **Api key**. Fill out the form and select **Create**.

Copy the client id and secret into a password manager before you close the dialog.

:::warning The secret is shown once
Walley cannot recover a lost secret. If you lose it, create a new key.
:::

## 2. Get an access token

Exchange the client id and secret for a token. Replace `{{clientId}}` and `{{clientSecret}}`
with your own values.

```bash
curl -X POST https://api.uat.walleydev.com/oauth2/v2.0/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id={{clientId}}" \
  -d "client_secret={{clientSecret}}" \
  -d "scope=705798e0-8cef-427c-ae00-6023deba29af/.default"
```

You get back a token and its lifetime in seconds:

```json
{
  "token_type": "Bearer",
  "expires_in": 3599,
  "ext_expires_in": 3599,
  "access_token": "bXlVc2VybmFtZTpmN2E1ODA4MGQzZTk0M2VmNWYyMTZlMDE..."
}
```

Cache the token and reuse it until `expires_in` runs out. To get a new one, repeat the same
request. For the full flow, see [Authentication](/docs/manage/getting-started/authentication).

## 3. Read an order

Call the Get order endpoint with the token in an `Authorization` header.

```bash
curl https://api.uat.walleydev.com/manage/orders/{{orderId}} \
  -H "Authorization: Bearer {{accessToken}}"
```

A `200 OK` response carries the order under `data`:

```json
{
  "data": {
    "id": "853f3f82-ab12-47c3-9d97-af17009852cd",
    "reference": "MX_220921_111434",
    "paymentMethod": "Invoice",
    "totalAmount": 2459.49,
    "currency": "SEK",
    "status": "Activated",
    "salesSegment": "B2C",
    "countryCode": "SE",
    "customer": {},
    "items": [],
    "invoices": []
  },
  "links": {},
  "metaData": {}
}
```

The `status` field decides what you can do next. See [Order lifecycle](/docs/manage/concepts/order-lifecycle).

## Where to go next

| You want to                                | Read                                                                     |
| ------------------------------------------ | ------------------------------------------------------------------------ |
| Know which actions an order allows         | [Order lifecycle](/docs/manage/concepts/order-lifecycle)                 |
| Understand why a change is not visible yet | [Asynchronous operations](/docs/manage/concepts/asynchronous-operations) |
| Confirm a shipment and trigger payout      | [Capture order](/docs/manage/orders/capture)                             |
| Give money back                            | [Refund order](/docs/manage/orders/refund)                               |
| Change an order before shipping            | [Reauthorize order](/docs/manage/orders/reauthorize)                     |
| Handle a failed request                    | [Errors](/docs/manage/errors)                                            |
