# Link accounts by code

Links the [platform account](/api/login/glossary-platform-account) to the existing [main account](/api/login/glossary-main-account) by the code.
To link accounts, the game server uses this call with the response from the [Create code for linking accounts](https://developers.xsolla.com/api/login/operation/create-code-for-linking-accounts) request.
**Notice**
[Rate limits for server-side methods](/api/login/rate-limits) are applied to this method.

Endpoint: POST /users/account/link
Version: v1
Security: Server

## Request fields (application/json):

  - `code` (string, required)
    Code by which service links accounts.

  - `platform` (string, required)
    Name of chosen Social Provider. Can be `steam`, `xbox`, `epicgames`, `psn`.

  - `project_id` (string)
    Shadow Login ID from Publisher Account.

**Shadow Login** is a project which ID you do not need to pass to this call. Contact your Customer Success Manager to set it up.

  - `publisher_project_id` (integer)
    Project ID from Publisher Account which you make a request for.

If you specify it, but do not specify the `project_id` parameter, the service will be linked to its `project_id`. Contact your Customer Success Manager to link `project_id` to `publisher_project_id`.

  - `user_id` (string, required)
    User ID from Social Provider.

## Response 400 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 401 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 404 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 422 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

## Response 429 fields (application/json):

  - `error` (object, required)

  - `error.code` (string, required)
    Error code.
    Example: 003-061

  - `error.description` (string, required)
    Error description.
    Example: Object not found.

  - `error.details` (object)
    Additional information.

