]> nmode's Git Repositories - signal-cli/blob - man/signal-cli-jsonrpc.5.adoc
Added base64 encoded attachment support (#966)
[signal-cli] / man / signal-cli-jsonrpc.5.adoc
1 /////
2 vim:set ts=4 sw=4 tw=82 noet:
3 /////
4
5 :quotes.~:
6
7 = signal-cli-jsonrpc (5)
8
9 == Name
10
11 signal-cli-jsonrpc - A commandline and dbus interface for the Signal messenger
12
13 == Synopsis
14
15 *signal-cli* [--verbose] [--config CONFIG] [-a ACCOUNT] daemon [--socket] [--tcp]
16
17 *signal-cli* [--verbose] [--config CONFIG] [-a ACCOUNT] jsonRpc
18
19 == Description
20
21 See signal-cli (1) for details on the application.
22
23 signal-cli provides a JSON-RPC based API with the `jsonRpc` and `daemon` commands.
24
25 - `jsonRpc` command accepts input on STDIN and responds on STDOUT.
26 This is intended to make it easier to embed signal-cli in other applications.
27
28 `signal-cli -a _ACCOUNT_ jsonRpc`
29
30 - `daemon` command provides a UNIX or TCP socket and can handle requests from multiple clients.
31
32 `signal-cli -a _ACCOUNT_ daemon --socket` or for multi-account mode `signal-cli daemon --socket`
33
34 == Basic usage
35
36 In JSON-RPC mode, signal-cli will read requests from stdin.
37 Every requests must be a JSON object in a single line.
38 Requests must have a unique "id" value to be able to match the response to the corresponding request.
39
40 Example:
41
42 REQUEST: `{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}`
43
44 RESPONSE: `{"jsonrpc":"2.0","result":[{"id":"Pmpi+EfPWmsxiomLe9Nx2XF9HOE483p6iKiFj65iMwI=","name":"My Group","description":"It's special because it is mine.","isMember":true,"isBlocked":false,"members":["+33123456789","+440123456789"],"pendingMembers":[],"requestingMembers":[],"admins":["+33123456789","+440123456789"],"groupInviteLink":"https://signal.group/#CjQKIAtcbUw482i7bqvmJCwdgvg0FMif52N5v9lGg_bE4U3zEhCjHKSaPzWImMpnCbU8A1r0"}],"id":"my special mark"}`
45
46 From the command line:
47
48 `echo '{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}' | signal-cli -u +33123456789 jsonRpc`
49
50 Like in dbus daemon mode, messages are automatically received in jsonRpc mode.
51 Incoming messages are sent as JSON-RPC notifications.
52
53 Example:
54
55 `{"jsonrpc":"2.0","method":"receive","params":{"envelope":{"source":"+33123456789","sourceNumber":"+33123456789","sourceUuid":"uuid","sourceName":"name","sourceDevice":1,"timestamp":1631458508784,"dataMessage":{"timestamp":1631458508784,"message":"foobar","expiresInSeconds":0,"viewOnce":false,"mentions":[],"attachments":[],"contacts":[]}}}}`
56
57 === Multi-account daemon mode
58 When the daemon command is started without an account parameter (-a), signal-cli will provide all local accounts and additional commands to register and link new accounts.
59
60 In multi-account mode, requests for a single account require an additional `account` param.
61
62 REQUEST: `{"jsonrpc":"2.0","method":"listGroups","id":"my special mark","params":{"account":"+33123456789"}}`
63
64 == Commands
65
66 The commands available for the JSON-RPC mode are the same as the cli commands (except `register`, `verify` and `link`).
67 The `method` field is the command name and the parameters can be sent as the `params` object.
68
69 - Parameter names are provided in camelCase format instead of the hyphen format on the cli.
70
71 e.g.: `--group-id=ID` on the cli becomes `"groupId":"ID"`
72
73 - Parameters that can take multiple values on the command line can be provided as single json value or as json array
74
75 e.g. `--attachment ATTACH1 ATTACH2` becomes `"attachments":["ATTACH1", "ATTACH2"]`
76
77 `--attachment ATTACH` becomes `"attachment":"ATTACH"`
78
79 === Additional JSON-RPC commands
80
81 For receiving message additional commands are provided in JSON-RPC mode with `--receive-mode=manual`.
82
83 ==== subscribeReceive
84
85 Tells the daemon to start receiving messages, returns the subscription id as a single integer value in the result.
86
87 ==== unsubscribeReceive
88
89 Stop a previous subscription for receiving messages.
90
91 Params:
92
93 - `subscription`: the subscription id returned by `subscribeReceive`
94
95 == Examples
96
97 REQUEST: `{"jsonrpc":"2.0","method":"listGroups","id":"5"}` RESPONSE: `{"jsonrpc":"2.0","result":[...],"id":"5"}`
98
99 REQUEST: `{"jsonrpc":"2.0","method":"send","params":{"recipient":["+YYY"],"message":"MESSAGE"},"id":4}` RESPONSE: `{"jsonrpc":"2.0","result":{"timestamp":999},"id":4}`
100
101 REQUEST: `{"jsonrpc":"2.0","method":"updateGroup","params":{"groupId":"GROUP_ID=","name":"new group name","members":["+ZZZ"],"link":"enabledWithApproval","setPermissionEditDetails":"only-admins"},"id":"someId"}` RESPONSE: `{"jsonrpc":"2.0","result":{"timestamp":9999},"id":"someId"}`
102
103 REQUEST: `{"jsonrpc":"2.0","method":"sendSyncRequest","id":9}` RESPONSE: `{"jsonrpc":"2.0","result":{},"id":9}`
104
105 REQUEST: `{"jsonrpc":"2.0"}` RESPONSE: `{"jsonrpc":"2.0","error":{"code":-32600,"message":"method field must be set","data":null},"id":null}`
106
107 == Authors
108
109 Maintained by AsamK <asamk@gmx.de>, who is assisted by other open source contributors.
110 For more information about signal-cli development, see
111 <https://github.com/AsamK/signal-cli>.