Documentation

Webshop Admin API reference

Explore the Webshop Admin API endpoints you can use to configure webshops, environments, themes, and branding programmatically.
Read time 3 minutesLast updated 15 days ago

The recommended best practice is for administrators to configure webshops in the Unity Dashboard.
Use the Webshop Admin API when the Unity Dashboard doesn't fit your workflow, such as when you need to do the following:
  • Update themes across many environments.
  • Script webshop creation as part of project setup.
  • Integrate webshop configuration into your deployment pipeline.
This page links to the API reference and explains how authentication and authorization work for admin-API calls.

Authentication

The Admin API uses Service Account credentials. Generate a Service Account key from the Unity Dashboard, base64-encode the
key_id:secret_key
pair, and send it in a Basic
Authorization
header:
Authorization: Basic <base64 of key_id:secret_key>
With curl,
-u "$KEY_ID:$SECRET_KEY"
builds this header for you.
For step-by-step instructions, refer to the Service Account authentication guide.

Authorization

Each Admin API endpoint requires a specific Service Account role. For the role list and the per-operation requirements, refer to Webshop permissions reference.

Set up a webshop with a script

A script, continuous integration (CI) job, or coding agent can take a project from no webshop to a published webshop that accepts payments in three calls: create the webshop, set the fallback payment provider, and publish. The Service Account needs the Webshop Editor role on the project.
The examples use these shell variables:
BASE_URL="https://services.unity.com/api/webshop/v1"CREDENTIALS="$KEY_ID:$SECRET_KEY"PROJECT_ID="<your project ID>"ENVIRONMENT_ID="<your production environment ID>"
Before you start, make sure you meet the following prerequisites:
  • At least one payment provider connected to the project. Refer to Payment providers.
  • At least one product in your In-App Purchasing (IAP) catalog that's available for web sale. These calls don't add products, and a webshop with an empty catalog renders without product cards. Refer to Catalog and payments in webshops.

Create the webshop

curl -X POST "$BASE_URL/projects/$PROJECT_ID/environments/$ENVIRONMENT_ID/webshop" \ -u "$CREDENTIALS" -H "Content-Type: application/json" \ -d '{"name": "My Game Shop", "slug": "my-game", "publisherSlug": "my-studio"}'
Use the project's production environment in the path. The webshop is published from the environment you create it in, and the Unity Dashboard publishes webshops only from production. An organization has one publisher, so if your organization already has a webshop, set
publisherSlug
to its existing publisher slug. A
409
response means the project already has a webshop, the slug is taken, or the publisher slug doesn't match your organization's publisher.

Set the fallback payment provider

curl -X PUT "$BASE_URL/projects/$PROJECT_ID/environments/$ENVIRONMENT_ID/webshop/payment-provider/configuration" \ -u "$CREDENTIALS" -H "Content-Type: application/json" \ -d '{"providerRouting": {}, "fallbackProvider": "stripe"}'
Without a fallback provider or a routing rule, players aren't offered a payment provider and can't check out. Use the provider name
stripe
or
codapay
. This call replaces the whole configuration, so include any routing rules you want to keep in
providerRouting
. For more information, refer to Set a fallback payment provider.
You can also add routing rules that offer specific providers to players with specific player tags. The fallback then applies only to players who match no rule. Routing rules depend on player tags that you set up outside the webshop, so add them in the Unity Dashboard. Refer to Payment provider routing in webshops.

Publish the webshop

curl -X POST "$BASE_URL/projects/$PROJECT_ID/environments/$ENVIRONMENT_ID/webshop/publish" \ -u "$CREDENTIALS"
A successful response can include a
warnings
array of non-fatal advisories, each prefixed with a stable code:
  • payment-routing-not-configured
    : the webshop has no fallback provider or routing rule, so players can't check out.
  • deep-link-not-configured
    : the webshop has no game deep link, so players can't connect their game account from the web or return to the game after a purchase. Refer to Open a webshop from your game.

API reference