summaryrefslogtreecommitdiffstats
path: root/doc/api/user.md
blob: 6500bfdc9d9db22263532e05676c8ec215329445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# /user API endpoints
**Table of Contents**

- [user/apikeys](#userapikeys)
- [user/create_apikey](#usercreate_apikey)
- [user/delete_apikey](#userdelete_apikey)

## user/apikeys

Required access level: `full`

Return apikeys of the user.

```javascript
// Success response
responseSuccess.data = {
    "apikeys": {
        apikey: {
            "key": apikey, // this is the same as the key of this object
            "created": Timestamp,
            "comment": String,
            "access_level": access-level,
        },
        ...
    },
]
```

Example:
```
> curl -s $base/user/apikeys -F apikey=$apikey | json_pp
{
   "data" : {
      "apikeys" : {
         "Sa71PVwKthRrrIEUIacqN9PNTouVQAWz" : {
            "key" : "Sa71PVwKthRrrIEUIacqN9PNTouVQAWz",
            "comment" : "fb-client flo@Marin",
            "created" : 1378389775,
            "access_level" : "full"
         },
      }
   },
   "status" : "success"
}
```

## user/create_apikey

Required access level: `full`

Create a new apikey.

This is the only endpoint that may be called without an apikey, but with username and password instead. Sending both, username/password and an api key results in undefined behaviour.

| POST field   | Type         | Comment |
| ----------   | ----         | ------- |
| username     | String       | Required if not called with api key. |
| password     | String       | Required if not called with api key. |
| access_level | access-level | Required |
| comment      | String       | Optional but recommended (username, hostname, client software name, ...). Maximum 255 chars. |


```javascript
// Success response
responseSuccess.data = {
    "new_key": String,
}
```

Example:
```
> curl -s $base/user/create_apikey -F username=test -F password=test -F access_level=apikey -F "comment=This is a test key" | json_pp
{
   "data" : {
      "new_key" : "2qXhd9E4ezBE53KiRtB5EE95r6m6ZeI1"
   },
   "status" : "success"
}
```

## user/delete_apikey

Required access level: `full`

Delete an apikey.

| POST field | Type   | Comment       |
| ---------- | ----   | -------       |
| delete_key | apikey | Key to delete |

| error_id                  | Message                                       | Note |
| --------                  | -------                                       | ---- |
| user/delete_apikey/failed | Apikey deletion failed. Possibly wrong owner. |      |

```javascript
// Success response
responseSuccess.data = {
    "deleted_keys": {
        apikey: {
            "key": apikey, // this is the same as the key of this object
        },
    },
}
```

Example:
```
> curl -s $base/user/delete_apikey -F apikey=$apikey -F delete_key=o0fDrc0LF8Kemqb9qzXXaScGsz9XCegj | json_pp
{
   "data" : {
      "deleted_keys" : {
         "o0fDrc0LF8Kemqb9qzXXaScGsz9XCegj" : {
            "key" : "o0fDrc0LF8Kemqb9qzXXaScGsz9XCegj"
         }
      }
   },
   "status" : "success"
}
```