API: create an order with POST
Purpose
POST /api/orders
creates an order through the same server logic as the form on the site (
createMsOrder
).
It is meant for:
- outside integrations;
- short links from admin tools;
- debugging the order flow.
Endpoint
- Method:
POST
- URL:
/api/orders
- Body: JSON (
MsCreateOrderPayload
, required)
Path to an order
An integration usually follows these steps:
- Load the listings
GET /api/events/
- Load the event
GET /api/events/[eventId]
- Load the seats still on sale
GET /api/events/[eventId]/tickets
- Choose
placeId
values from those seats
- Create the order
POST /api/orders
A practical sequence:
Guide for AI agents
The agent follows this algorithm without skipping a step.
Prompt to copy
You help people order tickets for events through the show-stolicy.ru API.
Answer in a warm, plain voice. No office jargon.
Assistant:
- Your name is Stolitsa.
- You are a city concierge: calm, precise, and polite.
- You know the pace of Moscow: you value speed, clarity, and a respectful tone.
- Use the formal "you" by default. Do not be familiar, and do not sound like a form.
- Be practical: offer two or three clear choices, not a long essay.
- After each step, say briefly what happened and what comes next.
- Do not pressure the guest, and do not use hard-sell language.
Your goal:
1) help the guest choose an event and seats;
2) collect the required details;
3) build a correct create-order request;
4) show a clear result (success or error, and what to do next).
Rules:
- Do not invent guest details, and do not fill required fields for them.
- Before creating an order, ask for:
- name (`customer.name`)
- email (`customer.email`)
- phone (`customer.phone`)
- If any required field is missing, do NOT create the order.
- Send the payload in `body` as valid UTF-8 JSON.
- Do not run several `create` requests at once for the same seats.
- Do not repeat `create` for the same seats without an explicit yes from the guest.
- Before a retry, always load `tickets` again.
Technical route:
1. `GET /api/events/` — pick an event with a non-empty `identifier`.
2. `GET /api/events/[eventId]` — confirm the event exists.
3. `GET /api/events/[eventId]/tickets` — load seats on sale.
4. Build `placeIds` from `itemOffered.ticketedSeat.identifier`:
- drop empty values and duplicates;
- if no seats remain, offer another event or date and stop.
5. Build the payload:
- `performanceId` = `eventId`
- `placeIds` = the chosen seats
- `customer.name`, `customer.email`, `customer.phone` are required
6. Send the payload as JSON `body` and call:
- `POST /api/orders`
7. Read the response:
- `200` and `ok=true` -> the order exists. You must:
- say the order was created;
- send the payment link (`paymentUrl`) in the chat;
- say a message with the order details should arrive at the guest's email now;
- show `orderId`, the amount, and the pay-by time.
- `400` -> explain the error in plain words and ask for the missing details.
- `429` -> say the limit is 3 orders from one IP per hour, and show `retryAfterSeconds`.
Voice:
- Write short, like a support manager.
- Ask first, then act.
- After each step, say what happened and what is next.
- If the guest says "place the order" and details are missing, ask only for those:
"Please share the name, email, and phone for the order."
Checklist before create:
- [ ] A valid `eventId`
- [ ] At least one `placeId`
- [ ] `customer.name`
- [ ] `customer.email`
- [ ] `customer.phone`
- [ ] Payload is UTF-8 JSON in `body`
What to tell the guest on success:
- "Done. The order is placed."
- "Order number: <orderId>"
- "To pay: <price> <currency>"
- "Payment link: <paymentUrl>"
- "Pay by: <paymentDueDate>"
- "A message with the order details should reach your inbox in the next few minutes."
- Call
GET /api/events/
and pick an event with a non-empty identifier
.
- Call
GET /api/events/[eventId]
and confirm the event exists.
- Call
GET /api/events/[eventId]/tickets
.
- Build
placeIds
from the ticket response:
- Build the payload:
performanceId
= eventId
;
placeIds
= the chosen seats;
customer.name
, customer.email
, and customer.phone
are required;
- other
customer
, order
, seller
, and orderDelivery
fields are optional.
- Send the payload as JSON
body
and call POST /api/orders
.
- Read the response:
status = 200
and ok = true
-> the order was created;
- otherwise the order was not created; return
message
.
Agent rules:
- do not run several create requests at once for the same seats;
- do not automatically repeat
create
for the same seats without a clear yes from the guest;
- before a retry, load
tickets
again (the seats may have gone);
- send the payload only as a JSON body, never as query parameters.
Suggested pseudocode
const events = await GET('/api/events/');
const eventId = pickEventId(events);
if (!eventId) throw new Error('No eventId');
await GET(`/api/events/${eventId}`);
const tickets = await GET(`/api/events/${eventId}/tickets`);
const placeIds = uniq(
tickets.data
.map((offer) => offer?.itemOffered?.ticketedSeat?.identifier?.trim())
.filter(Boolean)
);
if (!placeIds.length) throw new Error('No available places');
const payload = {
performanceId: eventId,
placeIds,
customer: {
name: 'Vyacheslav',
email: 'slav@belaev.dev',
phone: '+79771771877'
}
};
const order = await POST('/api/orders', payload);
Body format
The body is a JSON object
MsCreateOrderPayload
.
Required fields:
performanceId: string
placeIds: string[]
(at least one non-empty id)
customer.name: string
customer.email: string
customer.phone: string
Minimum payload
{
"performanceId": "12345",
"placeIds": ["place-1"],
"customer": {
"name": "Vyacheslav",
"email": "slav@belaev.dev",
"phone": "+79771771877"
}
}
Fuller payload
{
"performanceId": "12345",
"placeIds": ["place-1", "place-2"],
"customer": {
"surname": "Ivanov",
"name": "Ivan",
"patronymic": "",
"email": "customer@example.com",
"phone": "79990001122"
},
"order": {
"customer": {
"name": "Ivan Ivanov",
"email": "customer@example.com",
"telephone": "+7 999 000-11-22"
},
"seller": {
"identifier": "office-1",
"email": "seller@example.com"
},
"orderedItem": []
}
}
Calls
1) POST with a JSON body (cURL)
curl -X POST "/api/orders" \
-H "Content-Type: application/json" \
-d '{"performanceId":"12345","placeIds":["place-1"],"customer":{"name":"Vyacheslav","email":"slav@belaev.dev","phone":"+79771771877"}}'
2) POST with a JSON body (JavaScript)
const payload = {
performanceId: "12345",
placeIds: ["place-1", "place-2"]
};
const response = await fetch('/api/orders', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
UTF-8 for names
Responses
Success
Example:
{
"ok": true,
"orderId": "123456",
"basketId": "1715179200000",
"paymentUrl": "https://...",
"ttlInSeconds": 1200
}
Validation error
The live API writes
message
in Russian. The cases are:
- the body is not JSON;
performanceId
is missing;
placeIds
is missing;
customer.name
is missing;
customer.email
is missing;
customer.phone
is missing.
The provider rejected the order
- HTTP
400
ok: false
message
carries the error text
Rate limit
- Limit:
3
orders from one IP per 1
hour
- HTTP
429
ok: false
message
says there are too many create-order requests and to try later
retryAfterSeconds
is the wait until the next try
Notes
- This method really creates an order: it holds the seats, creates the order, builds the invoice and payment link, and sends notifications.
- For a production integration, call
POST /api/orders
and send the payload only as a JSON body.
- Encode names (
customer.name
, surname
, and the rest) as UTF-8.
- URL length limits no longer apply to the payload, because it travels in the body.