# Method: recall.linkPersona

- [HTTP request](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.HTTP_TEMPLATE)
- [Request body](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.request_body)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.response_body)
  - [JSON representation](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.LinkPersonaResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#body.aspect)
- [RecallTokensCardinalityConstraint](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#RecallTokensCardinalityConstraint)
- [ConflictingLinksResolutionPolicy](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#ConflictingLinksResolutionPolicy)
- [State](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#State)
- [Try it!](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#try-it)

Associate the PGS Player principal encoded in the provided recall session id with an in-game account

### HTTP request

`POST https://games.googleapis.com/games/v1/recall:linkPersona`

### Request body

The request body contains data with the following structure:

|                                                                                                                                                                                                                                                                  JSON representation                                                                                                                                                                                                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` { "sessionId": string, "persona": string, "token": string, "cardinalityConstraint": enum (https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#RecallTokensCardinalityConstraint), "conflictingLinksResolutionPolicy": enum (https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#ConflictingLinksResolutionPolicy), // Union field `expiration` can be only one of the following: "expireTime": string, "ttl": string // End of list of possible types for union field `expiration`. } ``` |

|                                                                                                                                                                            Fields                                                                                                                                                                            ||
|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sessionId`                        | `string` Required. Opaque server-generated string that encodes all the necessary information to identify the PGS player / Google user and application.                                                                                                                                                                   |
| `persona`                          | `string` Required. Stable identifier of the in-game account. Please refrain from re-using the same persona for different games.                                                                                                                                                                                          |
| `token`                            | `string` Required. Value of the token to create. Opaque to Play Games and assumed to be non-stable (encrypted with key rotation).                                                                                                                                                                                        |
| `cardinalityConstraint`            | `enum (`[RecallTokensCardinalityConstraint](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#RecallTokensCardinalityConstraint)`)` Required. Cardinality constraint to observe when linking a persona to a player in the scope of a game.                                                 |
| `conflictingLinksResolutionPolicy` | `enum (`[ConflictingLinksResolutionPolicy](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#ConflictingLinksResolutionPolicy)`)` Required. Resolution policy to apply when the linking of a persona to a player would result in violating the specified cardinality constraint.           |
| Union field`expiration`. Optional token expiration time or time to live.`expiration`can be only one of the following:                                                                                                                                                                                                                                        ||
| `expireTime`                       | `string (`[Timestamp](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp)` format)` Input only. Optional expiration time. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples:`"2014-10-02T15:01:23Z"`and`"2014-10-02T15:01:23.045123456Z"`. |
| `ttl`                              | `string (`[Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration)` format)` Input only. Optional time-to-live. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example:`"3.5s"`.                                                                                       |

### Response body

Outcome of a persona linking attempt.

If successful, the response body contains data with the following structure:

|                                                JSON representation                                                |
|-------------------------------------------------------------------------------------------------------------------|
| ``` { "state": enum (https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#State) } ``` |

|                                                                               Fields                                                                                ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | `enum (`[State](https://developer.android.com/games/services/web/api/rest/v1/recall/linkPersona#State)`)` Output only. State of a persona linking attempt. |

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/androidpublisher`

For more information, see the[OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2).

## RecallTokensCardinalityConstraint

Cardinality constraint to observe when linking a persona to a player in the scope of a game.

|                                                                                                                                                                                                                                                                                                                                                                                                                                 Enums                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ONE_PERSONA_TO_ONE_PLAYER` | 1:1 cardinality between in-game personas and Play Games Services players. By the end of the linking operation only one entry for the player and the persona should remain in the scope of the application. Whether a new link is created or not when this constraint is specified is determined by the chosen`ConflictingLinksResolutionPolicy`: - If`KEEP_EXISTING_LINKS`is specified and the provided persona is already linked to a different player, or the player is already linked to a different persona, no new link will be created and the already existing link(s) will remain as is(are). - If`CREATE_NEW_LINK`is specified and the provided persona is already linked to a different player, or the player is already linked to another persona, the older link(s) will be removed in favour of the new link being created. |

## ConflictingLinksResolutionPolicy

Resolution policy to apply when the linking of a persona to a player would result in violating the specified cardinality constraint.

|                                                                                                                                                                                                                                                                                                                                                                                                              Enums                                                                                                                                                                                                                                                                                                                                                                                                              ||
|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `KEEP_EXISTING_LINKS` | If link(s) between a player and persona already exists which would result in violating the specified`RecallTokensCardinalityConstraint`if the new link was created, keep the already existing link(s). For example, if Persona1-Player1 is already linked in the scope of application1 and a new link Persona1-Player2 is attempted to be created in the scope of application1, then the old link will remain and no new link will be added. Note that if the already existing links do violate the specified policy (which could occur if not all`recall.linkPersona`calls use the same`RecallTokensCardinalityConstraint`) this policy will leave these violations unresolved; in order to resolve conflicts, the {@link`CREATE_NEW_LINK`policy needs to be used to rewrite links resolving conflicts. |
| `CREATE_NEW_LINK`     | If an existing link between a player and persona already exists which would result in violating the specified`RecallTokensCardinalityConstraint`if the new link was created, replace the already existing link(s) with the new link. For example, if Persona1-Player1 is already linked in the scope of application1 and a new link Persona1-Player2 is attempted to be created in the scope of application1, then the old link will be removed and the new link will be added to replace it.                                                                                                                                                                                                                                                                                                            |

## State

State of a persona linking attempt.

|                                                                                                          Enums                                                                                                          ||
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `LINK_CREATED`                     | The link specified in the request was created.                                                                                                                                      |
| `PERSONA_OR_PLAYER_ALREADY_LINKED` | The link specified in the request was not created because already existing links would result in the new link violating the specified`RecallTokensCardinalityConstraint`if created. |