Documentation

​
​

Development

User Acquisition

Monetization

Industry

Friends API

v1

Supported
​

Friends API

v1

Supported
​

Unity Services Web APIs
​
​
Friends API
  • Overview
Endpoints
  • Messaging
  • Notifications
  • Presence
  • Relationships

Friends API

Overview

The Friends Service provides an HTTP API to manage user relationships of different types, and manage user presence.
We currently support the following types of Relationships:
  • FRIEND_REQUEST - an incoming or outgoing friend request.
  • FRIEND - an active friendship between two users that has been mutually accepted.
  • BLOCK - a one-way relationship that allows a user to block a different user in order to avoid game experiences with them.
Friends makes it quick and easy to create and update relationships and provides the tools needed to efficiently integrate standard Friends functionality into your game. The Presence features provide your players with the ability to advertise their current status in the game to other players, and support for custom presence metadata allows games to easily support features like join-in-progress or spectating.
Built-in support for push notifications allows players to easily manage their friends lists and be quickly notified when the presence of any user changes.
Download OpenAPI specification:

Retrieve a list of relationships.


Retrieves a list of all relationships a given user is involved in. Relationships of all types are returned in a single array. It's up to the caller to use the
type
of the relationship object to determine the appropriate way to handle that relationship. For relationship types that allow it, additional presence and profile data will be provided for each member of the relationship (unless excluded using the
withPresence
and
withProfile
parameters).
By default, we limit the number of relationships that can be returned in a single request. You can make subsequent requests to this API using the
offset
parameter to paginate through the remaining relationships.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Query parameters for "Retrieve a list of relationships."

limit

integer
default: 25
Maximum records to return per pagination. The default value is 25.

offset

integer
default: 0
Maximum offset for pagination. The default value is 0.

withPresence

boolean
default: true
Whether the response should return presence data.

withProfile

boolean
default: true
Whether the response should return profiles data.

type

array
default: FRIEND,BLOCK,FRIEND_REQUEST
The type of the relationship

HTTP response status codes for "Retrieve a list of relationships.":

Code samples for "Retrieve a list of relationships.":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/relationships"

Response example

[ { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "FRIEND", "members": [ { "id": "ce7a03c4-78a3-4b93-ab8a-ef066f5388bf" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "FRIEND", "members": [ { "id": "89e04c88-7c08-4a46-abe9-5b2089083c5c" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae72", "role": "TARGET" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae73", "role": "SOURCE" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "BLOCK", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae75" } ] }]

Create a new relationship.


Creates a relationship with one or more members. A relationship has a
type
and a list of
members
who are the users involved in the relationship. The requirements for creating a relationship are different depending on the
type
of the relationship.
Each member of the relationship can also be given an optional
role
which may indicate some semantic of the the relationship. A member can be identified by their user id or profile name.
For most relationships, if the caller is a user and is not included in the
members
list, that user's membership is inferred to exist using the appropriate role. For example, if you create a
FRIEND_REQUEST
relationship with one member, the caller is inferred to be the source of the relationship.

Relationship Types

FRIEND_REQUEST
Relationship

A
FRIEND_REQUEST
relationship indicates that a user would like to create a friendship with another user. If no
FRIEND
relationship (i.e. friendship) exists between the two users then the receiving game client will be notified that a
FRIEND_REQUEST
relationship has been created, and the game can choose to notify the user and provide a mechanism for them to accept the friend request. A friend request is accepted by creating a reciprocal
FRIEND_REQUEST
relationship targeting the originating user.
A
FRIEND_REQUEST
relationship can ONLY have two members. The members have a role of either
SOURCE
or
TARGET
to indicate the sender and the receiver of the request. If not provided the caller of the API will be inferred to be the
SOURCE
and the other member will be the
TARGET
. A user cannot create a relationship with themselves as the
TARGET
.

FRIEND
Relationship

A
FRIEND
relationship cannot be directly created by a user, but is implicitly created when both users have created
FRIEND_REQUEST
relationships with each other (i.e. sent and accepted a friend request).
A
FRIEND
relationship is not directed, so the
members
of the relationships do not have an assigned
role
.

BLOCK Relationship

A
BLOCK
relationship is a one-way relationship that enables a user to indicate that another user should be prevented from interacting with themselves for certain features and functionality (e.g. hiding presence, preventing the user from sending messages to them, etc.).
Presence blocking will be handled by the service to ensure that blocked users are unable to view the presence details of the blocker. For other functionality it is up to the developer to consume the
BLOCK
relationships data and provide additional functionality. For example, a game client could filter out lobbies created by users that have been blocked, or a game server could prevent a blocked user from joining a game instance.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Query parameters for "Create a new relationship."

withPresence

boolean
default: true
Whether the response should return presence data.

withProfile

boolean
default: true
Whether the response should return profiles data.

Request body for "Create a new relationship."

Media Type:
application/json

type

string
required
No description

members

array[object]
required
No description

profileName

string
No description

id

string
No description

role

string
No description

HTTP response status codes for "Create a new relationship.":

Code samples for "Create a new relationship.":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "type": "FRIEND", "members": [ { "profileName": "string", "id": "string", "role": "TARGET" } ]}' \ "https://social.services.api.unity.com/v1/relationships"

Response example

{ "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "s89e04c88-7c08-4a46-abe9-5b2089083c5c", "profile": { "name": "ColorfulFlickeringHat#9" }, "role": "TARGET" } ]}

Delete a relationship.


Deletes a relationship with the given
relationshipId
.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "Delete a relationship."

relationshipId

string
required
The relationship ID.

HTTP response status codes for "Delete a relationship.":

Code samples for "Delete a relationship.":

Request example

curl -X DELETE \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/relationships/{relationshipId}"

Response example

{ "type": "http://unity.com/relationships/invalid_relationship", "code": 24002, "requestID": "12345", "status": 400, "title": "Bad Request", "detail": "invalid relationship id"}

Send a message to a user.


Allows a user to send a message with a custom payload to another user. The Friends Service will only allow a user to send a message to a user that they have an active FRIEND relationship with.
The content of the payload can be customized entirely by the client. It is up to the client to determine how to best handle the message payload. For example, if the message payload contains a lobby ID, the client could show an Accept Invite toast. If the message contains a trade request, the client could enter a trading interface.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Request body for "Send a message to a user."

Media Type:
application/json

id

string
required
No description

message

object
required
The message to be sent to the target user. The maximum size of the message payload is 10 kilobytes.

HTTP response status codes for "Send a message to a user.":

Code samples for "Send a message to a user.":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "id": "string", "message": {}}' \ "https://social.services.api.unity.com/v1/message"

Response example

{ "type": "http://unity.com/relationships/invalid_relationship", "code": 24002, "requestID": "12345", "status": 400, "title": "Bad Request", "detail": "invalid relationship id"}

Get notification auth details.


Retrieves both a subscription token and a channel name that the user should use to subscribe to notifications. The Friends Service updates the notifications channel as changes to the user's relationships occur. This includes updates to the presence state of any friends, new friend requests (i.e.
FRIEND_REQUEST
relationships created), etc.
In general, the client should not depend on repeatedly polling the entire list of relationships to monitor for changes, but should instead fetch the entire list once and then register for notifications of any updates. This allows the client to keep the list up to date while minimizing overhead.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

HTTP response status codes for "Get notification auth details.":

Code samples for "Get notification auth details.":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/notifications/auth"

Response example

{ "token": "<notification_auth_jwt>", "channel": "<notification_channel>"}

Set presence for a user.


Updates the presence data for a user. This can be either or both of the availability and the activity.
Updates to the presence for a user will be pushed to all users with active FRIEND relationships with that user.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Request body for "Set presence for a user."

Media Type:
application/json

availability

string
required
The current availability of the user.

activity

object
The current activity data of the user. The maximum for the activity object is 10 kilobytes.

HTTP response status codes for "Set presence for a user.":

Code samples for "Set presence for a user.":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "availability": "ONLINE", "activity": {}}' \ "https://social.services.api.unity.com/v1/presence"

Response example

{ "availability": "ONLINE", "activity": { "location": "In Menu" }}

Get presence for a user.


Retrieves the presence data for a specific user. If the caller is a user, then the target user must be one that the caller has an active
FRIEND
relationship with.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "Get presence for a user."

userId

string
required
The userID.

HTTP response status codes for "Get presence for a user.":

Code samples for "Get presence for a user.":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/presence/{userId}"

Response example

{ "availability": "ONLINE", "activity": { "location": "In Menu" }}

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.