Mavis Store API reference
Overview
The Mavis Store API allows you to integrate your game with Mavis Store, enabling players to purchase in-game items with RON tokens. The API includes two types of endpoints:
- Outbound endpoints: used to send requests from Mavis Store to your server, such as delivering paid orders and verifying users
- Inbound endpoints: used to send requests from your server to Mavis Store, such as retrieving order statuses.
Authentication
The authentication process differs for outbound and inbound requests.
Outbound authentication
For outbound requests (from Mavis Store to your server), you authenticate using an API key generated in the Mavis Store CMS:
- Go to the Mavis Store sandbox CMS or production CMS.
- Log in with your Sky Mavis account used for merchant registration.
- Navigate to Store Settings > Settings and scroll to the Set up your API key section.
- Create a new API key and use it in the
X-API-KEY
header for requests sent by Mavis Store.
Inbound authentication
For inbound requests (from your server to Mavis Store), you authenticate using an API key generated in the Developer Console:
- Go to the Developer Console.
- Log in with your Sky Mavis Account used for merchant registration.
- Select the app created for Mavis Store integration.
- Copy your key from the KEY field on the Information tab, and use it in the
X-API-KEY
header for requests sent to Mavis Store.
Example authentication header:
-H 'X-API-KEY: {OUTBOUND_API_KEY}'
-H 'X-API-KEY: {INBOUND_API_KEY}'
Endpoints
Deliver paid order
After a user pays for an order, Mavis Store sends a request to your server to deliver the purchased items.
Retry mechanism: if the API returns a non-200
status or times out, Mavis Store retries the request up to three times, at intervals of 1 second, 5 minutes, and 15 minutes.
HTTP request:
POST https://{host}/deliver-items
Request body:
- On-chain items
- Off-chain items
{
"user_id": "0x9fce82995479fa41cc6f4aa1366f8df9eb574569",
"order_code": "ADBS5C7EOS",
"created_at": "2024-11-20T06:42:39.407535Z",
"payment_method": "ronin",
"transaction": {
"type": "purchase",
"code": "e47a7f97-2879-482f-a5b5-7e9c697ded35",
"external_id": "0x7c238981e23fae19bc584c9d98159ff3306c2b6e2659901a53d40346b99985f9",
"paid_by": "0x8E81aa0eA0455F6daAb482acdacEF30e5423A13c",
"price": {
"currency": "ron",
"token_address": "0x0000000000000000000000000000000000000000",
"amount": "1000000000000000000",
"decimals": 18
},
"created_at": "2024-11-20T06:42:56.911954Z"
},
"items": [
{
"sku": "onchain_item",
"quantity": 1,
"price": {
"currency": "ron",
"token_address": "0x0000000000000000000000000000000000000000",
"amount": "1000000000000000000",
"decimals": 18
}
}
]
}
Parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's Ronin address that receives the NFT. The user can manually enter this address in the storefront. |
order_code | String | Unique order identifier created by Mavis Store. |
created_at | String | Order creation timestamp in ISO 8601 format. |
payment_method | String | Payment method used, always set to ronin . |
items[index].sku | String | Unique SKU of the item as defined in the Mavis Store CMS. |
items[index].quantity | Integer | Quantity of the purchased item. |
items[index].price.currency | String | Currency of the item's price. |
items[index].price.amount | String | Item's price in the specified currency. |
items[index].price.decimals | Integer | Number of decimals for the token used in the item's price. |
items[index].price.token_address | String | Contract address for the token used in the item's price. |
transaction.type | String | Transaction type, always set to purchase . |
transaction.code | String | Transaction UUID generated by the Mavis Store server. |
transaction.external_id | String | Blockchain transaction hash on the Ronin chain. |
transaction.paid_by | String | User's Ronin address that made the payment. |
transaction.price.currency | String | Currency used for the transaction. |
transaction.price.amount | String | Amount of currency used for the transaction. |
transaction.price.decimals | Integer | Number of decimals for the token used in the transaction. |
transaction.price.token_address | String | Contract address for the token used in the transaction. |
transaction.created_at | String | Transaction creation timestamp in ISO 8601 format. |
{
"user_id": "1ed55b3a-3280-64ed-b821-ea6f994e7c22",
"order_code": "AG0A5UQ0UZ",
"created_at": "2024-11-20T06:44:02.368093Z",
"payment_method": "ronin",
"transaction": {
"type": "purchase",
"code": "508ed446-4560-4f8c-bdcd-abb5f3b33ecf",
"external_id": "0xcfd94437033ac823dc845565e4c924d361825d0f10e63390b86123fe7d63c182",
"paid_by": "0x8E81aa0eA0455F6daAb482acdacEF30e5423A13c",
"price": {
"currency": "ron",
"token_address": "0x0000000000000000000000000000000000000000",
"amount": "1000000000000000000",
"decimals": 18
},
"created_at": "2024-11-20T06:44:25.761675Z"
},
"items": [
{
"sku": "offchain_item",
"quantity": 1,
"price": {
"currency": "ron",
"token_address": "0x0000000000000000000000000000000000000000",
"amount": "1000000000000000000",
"decimals": 18
}
}
]
}
Parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
order_code | String | Unique order identifier created by Mavis Store. |
created_at | String | Order creation timestamp in ISO 8601 format. |
payment_method | String | Payment method used, always set to ronin . |
items[index].sku | String | Unique SKU of the item as defined in the Mavis Store CMS. |
items[index].quantity | Integer | Quantity of the purchased item. |
items[index].price.currency | String | Currency of the item's price. |
items[index].price.amount | String | Item's price in the specified currency. |
items[index].price.decimals | Integer | Number of decimals for the token used in the item's price. |
items[index].price.token_address | String | Contract address for the token used in the item's price. |
transaction.type | String | Transaction type, always set to purchase . |
transaction.code | String | Transaction UUID generated by the Mavis Store server. |
transaction.external_id | String | Blockchain transaction hash on the Ronin chain. |
transaction.paid_by | String | User's Ronin address that made the payment. |
transaction.price.currency | String | Currency used for the transaction. |
transaction.price.amount | String | Amount of currency used for the transaction. |
transaction.price.decimals | Integer | Number of decimals for the token used in the transaction. |
transaction.price.token_address | String | Contract address for the token used in the transaction. |
transaction.created_at | String | Transaction creation timestamp in ISO 8601 format. |
Response:
HTTP/1.1 200 OK
{
"message": "success"
}
Verify user
When the user views an item before placing an order, the storefront sends a GET request to this endpoint to verify whether the user ID entered by the user is valid.
HTTP request:
GET https://{host}/user?user_id={user_id}
Query parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
Response:
If the user exists, the API responds with the user's details:
HTTP/1.1 200 OK
{
"user_id": "12345",
"name": "Player12345"
}
Get personalized items
Checks whether a user is eligible to purchase specific items. It validates purchase criteria defined in merchant's system, such as stock availability or user-specific restrictions.
HTTP request:
GET https://{host}/items?user_id={user_id}&sku={sku}
Query parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
sku | String array | List of SKUs for the items as defined in the Mavis Store CMS. |
Response:
HTTP/1.1 200 OK
{
"user_id": "12345",
"items": [
{
"sku": "item001",
"stock": 10
},
{
"sku": "item002",
"stock": 0,
"reason": "Out of stock"
}
]
}
Response parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
item[index].sku | String | SKU of the item. |
item[index].stock | Integer | Remaining stock of the item that the user is eligible to purchase. If 0 , the item can't be purchased. |
item[index].reason | String | Reason why the item isn't available for purchase, displayed in the Mavis Store UI. Ensure that the reason is user-friendly. |
Validate order before checkout
Verifies whether a user can purchase specified items before processing the payment. It ensures the requested quantity is available and meets your system's rules.
HTTP request:
POST https://{host}/validate-items
Request body:
{
"user_id": "12345",
"items": [
{
"sku": "item001",
"quantity": 2
},
{
"sku": "item002",
"quantity": 1
}
]
}
Parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
items[index].sku | String | SKU of the item as defined in the Mavis Store CMS. |
items[index].quantity | Integer | Quantity of the item requested by the user. |
Response:
HTTP/1.1 200 OK
{
"user_id": "12345",
"items": [
{
"sku": "item001",
"tx_hash": "8d9c5e61-10b8-4b8c-95b8-be2ae55a0631"
},
{
"sku": "item002",
"tx_hash": "ef181a49-cdc3-4256-aaf5-711f94b6c691"
}
]
}
Parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
items[index].sku | String | Unique alphanumeric ID of the item. |
items[index].tx_hash | String | UUID generated by the merchant's server. You can lock and prevent the user from buying more than the allowed quantity. |
Cancel pre-validation
Request the cancellation of a pre-validated order.
HTTP request:
POST https://host/cancel-pre-validation
Request body:
{
"user_id": "12345",
"items": [
{
"sku": "item001",
"tx_hash": "8d9c5e61-10b8-4b8c-95b8-be2ae55a0631"
}
]
}
Parameters:
Parameter | Type | Description |
---|---|---|
user_id | String | User's unique identifier in the Sky Mavis Account service (if integrated) or in the merchant's system. |
items[index].sku | String | Unique alphanumeric ID of the item. The SKU must be an exact match with the item information metadata that you define when listing the item in the store. |
items[index].tx_hash | String | UUID generated by the merchant's server. |
Response:
{
"message": "success"
}
Get order by code
Retrieve the status and details of an order from Mavis Store.
GET
https://api-gateway.skymavis.com/store/v1/partner/order/{order_code}
Request parameters:
Parameter | Type | Description |
---|---|---|
order_code | String | Unique order code created for this order. |
Response:
{
"code": "AD3PHSPON7",
"user_id": "0x210744c64eea863cf0f972e5aebc683b98fb1981",
"status": "completed",
"payment_method": "ronin",
"transactions": [
{
"type": "purchase",
"external_id": "0x1db7f5d5886f1f13ea321641f2e70f87624b18bf23149473a539a7c44e9ff4f1",
"paid_by": "0x8E81aa0eA0455F6daAb482acdacEF30e5423A13c",
"created_at": "2024-06-24T08:38:54.727921Z"
}
]
"items": [
{
"sku": "review-gem-008",
"quantity": 1,
"sub_total": "990000"
}
],
"expired_at": "2024-06-24T15:40:13.081613+07:00",
"created_at": "2024-06-24T15:25:13.081613+07:00"
}
Response parameters:
Parameter | Type | Description |
---|---|---|
code | String | Unique order code created for this order. |
user_id | String | User's Ronin address that receives the NFT. |
status | String | Order status. |
payment_method | String | Payment method used. |
transactions | Array | Array of transactions. |
transactions[index].type | String | Transaction type as purchase . |
transactions[index].external_id | String | Transaction hash on the Ronin chain. |
transaction[index].paid_by | String | User's Ronin address that made the payment. |
transactions[index].created_at | String | Transaction creation date. |
items | Array | Array of items in the order. |
items[index].sku | String | Unique alphanumeric ID of the item. |
items[index].quantity | Integer | Item quantity. |
items[index].sub_total | String | Subtotal of the item (item price times quantity). |
expired_at | String | Order expiration date. |
created_at | String | Order creation date. |
Order status flow
Backend | Storefront | Description |
---|---|---|
new | Unpaid | Order is created but not paid. |
paying | Pending | User is making payment for the order. |
paid | Paid | Order is paid for. |
completed | Completed | Order is delivered successfully. |
delivered_failed | Paid | Delivery failed due to server issues. |
delivered_rejected | Paid | Order was rejected by the server. |
cancelled | Cancelled | Order was cancelled by the user or system. |
Status codes
The following table lists the HTTP status codes and corresponding error codes your server returns to Mavis Store:
Status code | Error code | Description |
---|---|---|
200 | - | Success |
400 | INVALID_PARAMETER | A parameter in the request is invalid. |
400 | ITEM_OUT_OF_STOCK | The item is out of stock. |
400 | ITEM_EXPIRED | The item validation time has expired. |
400 | INVALID_PURCHASING_AMOUNT | The user can't buy the item with the requested quantity. |
401 | UNAUTHORIZED | Invalid authentication credentials. |
404 | USER_NOT_EXISTS | The user doesn't exist in the system. |
404 | ITEM_NOT_FOUND | The item isn't available in the system. |
500 | INTERNAL_SERVER | An internal server error occurred. |
503 | SERVICE_UNAVAILABLE | The service is not available. |
Error response example:
{
"code": "INVALID_PARAMETER",
"message": "Invalid user_id provided."
}