Ticket Endpoint
The SDK's HttpTicketProvider POSTs to a URL on your own backend. That endpoint authenticates
the player however you already do, then asks Pairiquium for a ticket and passes the result back.
This keeps your API key on your server.
Never call Pairiquium's ticket endpoint from the game
POST /v1/tickets needs your secret API key. Anything in a game build can be extracted, so the
call must be made by your backend. See Generate a Ticket.
What the SDK expects from your endpoint
- Request: a
POST. When the game asks for a specific region, the body is{ "preferredRegion": "us-east-1" }; otherwise there is no body. - Response:
200with JSON containing bothticketandwsEndpoint, the same shape Pairiquium returns.
If your endpoint doesn't fit this shape, write your own provider instead; see Custom Providers & Platforms.
Example backend (Node.js)
app.post('/matchmaking/ticket', requirePlayerLogin, async (req, res) => {
const response = await fetch('https://api.pairiquium.com/v1/tickets', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-MaaS-API-Key': process.env.PAIRIQUIUM_API_KEY,
},
body: JSON.stringify({
userId: req.player.id, // your own player ID
preferredRegion: req.body?.preferredRegion, // omitted when undefined
}),
});
if (!response.ok) return res.status(502).json({ error: 'ticket_unavailable' });
const { ticket, wsEndpoint } = await response.json();
res.json({ ticket, wsEndpoint });
});userId is your own identifier for the player. It comes back unchanged in the
match webhook, which is how you tie a match to a
player. Pass attrs too (for example { mmr: 1500 }) if the player will queue for an MMR-based
game mode. The full request is in Generate a Ticket.
Authenticating the player to your backend
Your endpoint needs to know who is asking. HttpTicketProvider takes an optional hook that runs
before every request, which is the place to attach the player's session token:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Pairiquium.Tickets;
var tickets = new HttpTicketProvider(
httpClient,
new Uri("https://your-backend.example.com/matchmaking/ticket"),
(request, cancellationToken) =>
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", session.Token);
return Task.CompletedTask;
});The hook runs for every ticket request, so reconnects use the current token. Reuse a single
HttpClient for the life of your game rather than creating one per request.
Next
With the endpoint in place, run your first search: Quick Start.