> For the complete documentation index, see [llms.txt](https://docs.coherence.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherence.io/0.9/api-reference/cloud-api/matchmaking.md).

# Matchmaking

## Coherence.Runtime.Matchmaking

{% hint style="warning" %}
The player needs to be [logged in](/0.9/api-reference/cloud-api/game-account.md) to use matchmaking.
{% endhint %}

The matchmaking module has only one method.

```csharp
// Invoked on success/failure
public delegate void OnMatch(Result result, MatchResponse match);

// The data for every player returned by the matchmaking request
public struct PlayerPayload
{
    public string UserId;
    public string Team;
    public int Score;
    public string Payload;
}

// The response of the matchmaking request
public class MatchResponse
{
    public string MatchId;
    public PlayerPayload[] Players;
    public string Error;
}

public static class Matchmaker
{
    // Sends matchmaking request.
    // region:  matchmaking region, e.g. eu, us, ...
    // team:    team name
    // payload: custom string that will be send to all other players
    public static async Task<MatchResponse> Match(string region, string team, string payload)
    
    // Sends a matchmaking request
    // region:  matchmaking region, e.g. eu, us, ...
    // team:    team name
    // payload: custom string that will be send to all other players
    // tags:    custom tags to segment the player pool, e.g. "level1", "qa", etc
    // friends: group the player with his friends. If any of the friends doesn't show up the request will fail
    public static async Task<MatchResponse> Match(string region, string team, string payload, string[] tags, string[] friends)
}
```

## Example

```csharp
var res = await Matchmaker.Match("eu", "blue", "car:volvo,rifle:glock");
if (!string.IsNullOrEmpty(res.Error))
{
    // some kind of error, inform the plaeyr
    return;
}

// res.Players contain all the matched players and their data
// including the this player
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coherence.io/0.9/api-reference/cloud-api/matchmaking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
