Making your first API order in synchronous mode
As we are using the playground, the base URL is https://playground.runa.io/v2
, we will be making a call to the POST /order
endpoint. The full path therefore is https://playground.runa.io/v2/order
.
To successfully place an order, you need to include the following headers in your API request:
The API key you created in the previous step.
A unique value that we use to prevent duplicate purchases. If a network error occurs, you can retry the request with the same idempotency key and we will return the original order without any danger of creating a new one. You can read more about how we handle this field in the idempotency guide.
For testing you can just make one up, but you must generate a unique value for each order you intend to make. We suggest using a V4 UUID for this field.
The API version you want to use. This header is optional but we highly
recommend you to set it. For this guide, we will use the latest version
2024-02-05
Set the value of this header to sync
as we are using the synchronous
execution mode for this guide. If omitted, the default value is async
.
Putting this all together the full headers we need to send are:
The request body is a JSON object that defines the order we are about to place. We need to define the payment method and the items we want to order, and how we want to distribute the payout link to the end users.
Here’s the outline of the request body we will be constructing, read on to see how to fill in the details.
The payment method is the balance you want to use to pay for the order. For simplicity we will match the currency of the payout link we are about to order. The following fields are set on the payment_method
object:
Set the payment method type as ACCOUNT_BALANCE
For this example, we will use the currency USD
As we are using the synchronous execution mode, we can only order a single payout link at a time. The following fields are set on the single item within the items
array:
Indicate the face value of the payout link you wish to order. The currency will be based on the selected product. As the product is in USD this will be $10.
We have a choice here between EMAIL
and PAYOUT_LINK
. Read on to see how to
set these fields.
We have a choice here between SINGLE
and MULTIPLE
and TEMPLATE
. Read on to see how to set these fields.
As mentioned we have two options here, EMAIL
and PAYOUT_LINK
.
EMAIL
: This will send the payout link directly to the end user’s email inbox.PAYOUT_LINK
: This will return the payout link in the response body.RECIPIENT
: This is used for payment type products, we won’t be using this in this guide.EMAIL
Set the distribution method type as EMAIL
Set the email address you want to send this payout link to.
The playground environment by default does not send emails. To enable this, you need to set the X-Send-Email: true
header.
Ensure you refer to the playground reference for more details.
PAYOUT_LINK
Set the distribution method type as PAYOUT_LINK
There are three options here, SINGLE
, MULTIPLE
and TEMPLATE
.
SINGLE
: This will create a payout link for the selected product, the end user will receive a link for the chosen value exactly.MULTIPLE
: This will create payout link where the end user can choose to split the value between multiple products.TEMPLATE
: This will create a payout link as defined by a pre-built template.As we’ve not pulled the product catalog we’ll use TEMPLATE
for this example. In the playground environment we have a pre-defined template we can use for USD that will give us a payout link with 10 randomized products.
On the products
object we will set the type
to TEMPLATE
and the template_id
to PT-01HQ12PV4B8XMBRTK281JM54KK
. The template_id
is the ID of the template we want to use.
Set the product selection type to TEMPLATE
Set the template ID to PT-01HQ12PV4B8XMBRTK281JM54KK
, a pre-defined
playground
template
for USD.
Here’s the complete request we’ll be sending to the API.
The response will be a 200 OK
with the order details in the body. You can retrieve the payout link from the payout.url
field from the items
array.
Pop the url
field into your browser to see the payout link. Congratulations, you’ve just made your first order with Runa.
You can now explore the following features to take your first order to the next level.
To make orders for specific products you’ll need to fetch the product catalog first.
Add your own branding and customize the redemption experience for your recipients.
Use Runa Embedded FX to pay for an order using your funds in another currency
Alternatively, you can explore the steps needed to make real orders in the production environment.
Once you’re ready to go live have a look at the production checklist.
Making your first API order in synchronous mode
As we are using the playground, the base URL is https://playground.runa.io/v2
, we will be making a call to the POST /order
endpoint. The full path therefore is https://playground.runa.io/v2/order
.
To successfully place an order, you need to include the following headers in your API request:
The API key you created in the previous step.
A unique value that we use to prevent duplicate purchases. If a network error occurs, you can retry the request with the same idempotency key and we will return the original order without any danger of creating a new one. You can read more about how we handle this field in the idempotency guide.
For testing you can just make one up, but you must generate a unique value for each order you intend to make. We suggest using a V4 UUID for this field.
The API version you want to use. This header is optional but we highly
recommend you to set it. For this guide, we will use the latest version
2024-02-05
Set the value of this header to sync
as we are using the synchronous
execution mode for this guide. If omitted, the default value is async
.
Putting this all together the full headers we need to send are:
The request body is a JSON object that defines the order we are about to place. We need to define the payment method and the items we want to order, and how we want to distribute the payout link to the end users.
Here’s the outline of the request body we will be constructing, read on to see how to fill in the details.
The payment method is the balance you want to use to pay for the order. For simplicity we will match the currency of the payout link we are about to order. The following fields are set on the payment_method
object:
Set the payment method type as ACCOUNT_BALANCE
For this example, we will use the currency USD
As we are using the synchronous execution mode, we can only order a single payout link at a time. The following fields are set on the single item within the items
array:
Indicate the face value of the payout link you wish to order. The currency will be based on the selected product. As the product is in USD this will be $10.
We have a choice here between EMAIL
and PAYOUT_LINK
. Read on to see how to
set these fields.
We have a choice here between SINGLE
and MULTIPLE
and TEMPLATE
. Read on to see how to set these fields.
As mentioned we have two options here, EMAIL
and PAYOUT_LINK
.
EMAIL
: This will send the payout link directly to the end user’s email inbox.PAYOUT_LINK
: This will return the payout link in the response body.RECIPIENT
: This is used for payment type products, we won’t be using this in this guide.EMAIL
Set the distribution method type as EMAIL
Set the email address you want to send this payout link to.
The playground environment by default does not send emails. To enable this, you need to set the X-Send-Email: true
header.
Ensure you refer to the playground reference for more details.
PAYOUT_LINK
Set the distribution method type as PAYOUT_LINK
There are three options here, SINGLE
, MULTIPLE
and TEMPLATE
.
SINGLE
: This will create a payout link for the selected product, the end user will receive a link for the chosen value exactly.MULTIPLE
: This will create payout link where the end user can choose to split the value between multiple products.TEMPLATE
: This will create a payout link as defined by a pre-built template.As we’ve not pulled the product catalog we’ll use TEMPLATE
for this example. In the playground environment we have a pre-defined template we can use for USD that will give us a payout link with 10 randomized products.
On the products
object we will set the type
to TEMPLATE
and the template_id
to PT-01HQ12PV4B8XMBRTK281JM54KK
. The template_id
is the ID of the template we want to use.
Set the product selection type to TEMPLATE
Set the template ID to PT-01HQ12PV4B8XMBRTK281JM54KK
, a pre-defined
playground
template
for USD.
Here’s the complete request we’ll be sending to the API.
The response will be a 200 OK
with the order details in the body. You can retrieve the payout link from the payout.url
field from the items
array.
Pop the url
field into your browser to see the payout link. Congratulations, you’ve just made your first order with Runa.
You can now explore the following features to take your first order to the next level.
To make orders for specific products you’ll need to fetch the product catalog first.
Add your own branding and customize the redemption experience for your recipients.
Use Runa Embedded FX to pay for an order using your funds in another currency
Alternatively, you can explore the steps needed to make real orders in the production environment.
Once you’re ready to go live have a look at the production checklist.