Client API Proxy

All operations documented within the Server APIs are designed to give an administrative level of access to data; as such, the data and operations tend not to be user specific. What does this mean?

  • You will see a global perspective of Messages; this means that properties such as received_at which are specific to individual users can’t be part of the results as each user has their own received_at
  • You will see a global perspective of Conversations; this means that properties such as last_message which may vary among users. This is especially true for those who have done a DELETE operation removing it using mode=my_devices rather than mode=all_participants, gaurenteeing differences in Message lists and last_message between users

Sometimes however, its useful to be able to view data from the perspective of a specific user, and even perform actions on that user’s behalf. Some examples include:

  • Get the user’s message list, process it, and then deliver it to the user
  • Send a Message or Read Receipt on behalf of the user
  • Delete data that is no longer relevant to this user

The Client API Proxy allows the Server API to route authenticated requests to the Client API. Why not just use the Client API directly? Because authentication with the Server API is done using a single Bearer Token; each user needs a separate session token to access their data via the Client API, which can result in a lot of runs through Layer’s authentication process to manage a large user group.

Requests sent to https://api.layer.com/apps/YOUR_APP_ID/users/USER_ID/endpoint will be treated as a Client API Proxy request.

Note

User management requests use the same URL, and are not sent to the Client API; any request you see in the Server API’s User Management will be handled by the Server API.

To understand what requests are possible, and learn about the API for these requests, see the Client API Reference.

Examples are below:

GET/apps/:app_uuid/users/:user_id/conversations

This request will return an array of Conversations that the user has access to.

POST/apps/:app_uuid/users/:user_id/conversations/:conversation_uuid/messages

This request will send a Message on behalf of the user

POST/apps/:app_uuid/users/:user_id/messages/:message_id/receipts

This request will send a Read/Delivery Receipt on behalf of the user

DELETE/apps/:app_uuid/users/:user_id/messages/:message_id

This request will delete a Message on behalf of the user