Getting started
Performing requests
- Instantiate a protobuf message called
ClientRequest
. - Initiate a
POST
request to the/exec
endpoint, including the serialized message in the request body. Set the content type toapplication/x-protobuf
. - Deserialize the response body into a
ServerResponse
protobuf message. - Examine the error field within the response to identify potential server errors.
Requests
All requests are sent to the /exec
endpoint. Each request is a protobuf message of ClientRequest
type.
ca2.ClientRequest
message ClientRequest {
bytes trx = 1;
string token = 2;
ca2auth.Request auth = 11;
ca2billing.Request billing = 16;
ca2instances.Request instances = 17;
ca2referrals.Request referrals = 14;
ca2servers.Request servers = 15;
ca2ssh.Request ssh = 13;
ca2users.Request users = 12;
ca2utils.Request utils = 10;
ca2domains.Request domains = 18;
}
Each response is a protobuf message of ServerResponse
type.
ca2.ServerResponse
message ServerResponse {
bytes trx = 1;
repeated ca2.ServerError errors = 2;
ca2auth.Response auth = 11;
ca2billing.Response billing = 16;
ca2instances.Response instances = 17;
ca2referrals.Response referrals = 14;
ca2servers.Response servers = 15;
ca2ssh.Response ssh = 13;
ca2users.Response users = 12;
ca2utils.Response utils = 10;
ca2domains.Response domains = 18;
}
ca2.ServerError
See API reference for more information.
WebSockets
The WebSocket is available at the /ws
endpoint. After connecting to the WebSocket, the client should send a WsAuth
message to the server:
After the server receives the WsAuth
message with a valid token, it will immediately send empty WsEvent
message.
Next on every event, the server will send a WsEvent
message with the data.
Client can break the connection every time.
When client is offline, all events are lost. The server does not store any events. So after the client reconnects, it should request the missing data with the synchronous requests.
sequenceDiagram
participant Client
participant Server
Client->>+Server: Create WebSocket connection
Client->>+Server: WsAuth (with token)
Server->>+Client: WsEvent (empty)
loop
Server->>+Client: WsEvent (with data)
end
Client->>+Server: Break connection
Errors on WebSocket
In case of an error (e.g. invalid token), the WsEvent
message contains ServerErrors
same as in the synchronous requests.
ca2.ServerError
After sending the WsEvent
message with errors, the server will break the connection.
sequenceDiagram
participant Client
participant Server
Client->>+Server: Create WebSocket connection
Client->>+Server: WsAuth (with token)
Server->>+Client: WsEvent (with errors)
Server->>+Client: Break connection