sylvia-iot-auth 0.3.7

The authentication/authorization module of the Sylvia-IoT platform.
Documentation
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
API - Auth
==========

## Contents

- [Notes]#notes
- [Common error codes]#errcode
- [Roles]#roles
- [Service APIs]#service
    - [`GET /version` Get service version]#get_version
- [Auth APIs]#auth
    - [`GET /auth/api/v1/auth/tokeninfo` Get token information]#get_auth_tokeninfo
    - [`POST /auth/api/v1/auth/logout` Log-out the user]#post_auth_logout
- [User information APIs]#user
    - [`GET /auth/api/v1/user` Get user information]#get_user
    - [`PATCH /auth/api/v1/user` Update user information]#patch_user
- [User administration APIs]#admin
    - [`POST /auth/api/v1/user` Create user]#post_admin_user
    - [`GET /auth/api/v1/user/count` User count]#get_admin_user_count
    - [`GET /auth/api/v1/user/list` User list]#get_admin_user_list
    - [`GET /auth/api/v1/user/{userId}` Get user information]#get_admin_user
    - [`PATCH /auth/api/v1/user/{userId}` Update user information]#patch_admin_user
    - [`DELETE /auth/api/v1/user/{userId}` Delete user]#delete_admin_user
- [Client administration APIs]#client
    - [`POST /auth/api/v1/client` Create client]#post_client
    - [`GET /auth/api/v1/client/count` Client count]#get_client_count
    - [`GET /auth/api/v1/client/list` Client list]#get_client_list
    - [`GET /auth/api/v1/client/{clientId}` Get client information]#get_client
    - [`PATCH /auth/api/v1/client/{clientId}` Update client information]#patch_client
    - [`DELETE /auth/api/v1/client/{clientId}` Delete client]#delete_client
    - [`DELETE /auth/api/v1/client/user/{userId}` Delete user clients]#delete_client_user

## <a name="notes"></a>Notes

All API requests (except `GET /version`) must have a **Authorization** header with a **Bearer** token.

- **Example**

    ```http
    GET /auth/api/v1/user HTTP/1.1
    Host: localhost
    Authorization: Bearer 766f29fa8691c81b749c0f316a7af4b7d303e45bf4000fe5829365d37caec2a4
    ```

All APIs may respond one of the following status codes:

- **200 OK**: The request is success with body.
- **204 No Content**: The request is success without body.
- **400 Bad Request**: The API request has something wrong.
- **401 Unauthorized**: The access token is invalid or expired.
- **403 Forbidden**: The user does not have the permission to operate APIs.
- **404 Not Found**: The resource (in path) does not exist.
- **500 Internal Server Error**: The server is crash or get an unknown error. You should respond to the system administrators to solve the problem.
- **503 Service Unavailable**: The server has something wrong. Please try again later.

All error responses have the following parameters in JSON format string:

- *string* `code`: The error code.
- *string* `message`: (**optional**) The error message.

- **Example**

    ```http
    HTTP/1.1 401 Unauthorized
    Access-Control-Allow-Origin: *
    Content-Type: application/json
    Content-Length: 70
    ETag: W/"43-Npr+dy47IJFtraEIw6D8mYLw7Ws"
    Date: Thu, 13 Jan 2022 07:46:09 GMT
    Connection: keep-alive

    {"code":"err_auth","message":"Invalid token: access token is invalid"}
    ```

## <a name="errcode"></a>Common error codes

The following are common error codes. The API specific error codes are listed in each API response documents.

- **401** `err_auth`: Authorization code error. Please refresh a new token.
- **503** `err_db`: Database operation error. Please try again later.
- **503** `err_intmsg`: Inter-service communication error. Please try again later.
- **404** `err_not_found`: The request resource (normally in path) not found.
- **400** `err_param`: Request input format error. Please check request parameters.
- **403** `err_perm`: Permission fail. This usually means that API requests with an invalid user role.
- **503** `err_rsc`: Resource allocation error. Please try again later.
- **500** `err_unknown`: Unknown error. This usually means that the server causes bugs or unexpected errors.

## <a name="roles"></a>Roles

This system supports the following roles:

- `admin`: The system administrator.
- `dev`: The 3rd party developer.
- `manager`: The system manager who can manage users' information.
- `service`: The web service.

**Normal user** means users without any roles.

# <a name="service"></a>Service APIs

## <a name="get_version"></a>Get service version

Get service name and version information.

    GET /version?
        q={query}

- *string* `q`: (**optional**) To query the specific information **in plain text**. You can use:
    - `name`: To query the service name.
    - `version`: To query current version.

#### Response

- **200 OK**: Version information. Parameters are:

    - *object* `data`:
        - *string* `name`: The service name.
        - *string* `version`: Current version.

    - **Example**

        ```json
        {
            "data": {
                "name": "sylvia-iot-auth",
                "version": "1.0.0"
            }
        }
        ```

    - **Example** when `q=name`:

        ```
        sylvia-iot-auth
        ```

    - **Example** when `q=version`:

        ```
        1.0.0
        ```

# <a name="auth"></a>Auth APIs

These APIs can be used by all users.

## <a name="get_auth_tokeninfo"></a>Get token information

Get token information.

    GET /auth/api/v1/auth/tokeninfo

#### Response

- **200 OK**: Token information. Parameters are:

    - *object* `data`:
        - *string* `userId`: User ID.
        - *string* `account`: User account.
        - *string* `name`: User display name.
        - *object* `roles`: Roles with `{role}:true/false` format.
        - *string* `clientId`: Associated client ID.
        - *string[]* `scopes`: Allowed scopes.

- **400, 401, 500, 503**: See [Notes]#notes.

## <a name="post_auth_logout"></a>Log-out the user

Log-out all the user's sessions with the access token.

    POST /auth/api/v1/auth/logout

#### Response

- **204, 400, 401, 500, 503**: See [Notes]#notes.

# <a name="user"></a>User information APIs

These APIs can be used by all users.

## <a name="get_user"></a>Get user information

Get user self information.

    GET /auth/api/v1/user

#### Response

- **200 OK**: User information. Parameters are:

    - *object* `data`:
        - *string* `account`: User account.
        - *string* `createdAt`: Creation time in RFC 3339 format.
        - *string* `modifiedAt`: Creation time in RFC 3339 format.
        - *string | null* `verifiedAt`: Verification time in RFC 3339 format.
        - *object* `roles`: (**present for special roles**) Roles.
        - *string* `name`: Display name.
        - *object* `info`: Other information.

    - **Example**

        ```json
        {
            "data": {
                "account": "michael-johnson@example.com",
                "createdAt": "2022-01-01T02:23:47.053Z",
                "modifiedAt": "2022-01-02T05:17:27.129Z",
                "validated": "2022-01-01T02:26:52.210Z",
                "name": "Michael",
                "info": {
                    "firstName": "Michael",
                    "lastName": "Johnson",
                    "phoneNumber": "0987654321"
                }
            }
        }
        ```

- **400, 401, 500, 503**: See [Notes]#notes.

## <a name="patch_user"></a>Update user information

Update user self information.

    PATCH /auth/api/v1/user

#### Additional HTTP Headers

    Content-Type: application/json

#### Parameters

- *object* `data`:
    - *string* `password`: (**optional**) User password.
    - *string* `name`: (**optional**) The display name.
    - *object* `info`: (**optional**) Other information.

- **Note**: You must give at least one parameter.

- **Example**

    ```json
    {
        "data": {
            "name": "Michael",
            "info": {
                "firstName": "Michael",
                "lastName": "Johnson",
                "address": "123, abc road, def city",
                "phoneNumber": "123456"
            }
        }
    }
    ```

#### Response

- **204 No Content**
- **400, 401, 500, 503**: See [Notes]#notes.

# <a name="admin"></a>User administration APIs

These APIs can be used by system administrators only, for managers except:

- `GET /auth/api/v1/user/count`
- `GET /auth/api/v1/user/list`
- `GET /auth/api/v1/user/{userId}`
- `PATCH /auth/api/v1/user/{userId}`: (limited)

## <a name="post_admin_user"></a>Create user

Create a user.

    POST /auth/api/v1/user

#### Additional HTTP Headers

    Content-Type: application/json

#### Parameters

- *object* `data`:
    - *string* `account`: User account. Must be **email address** format or the pattern `[A-Za-z0-9]{1}[A-Za-z0-9-_]*`. The account will be transformed to lowercase.
    - *string* `password`: Password.
    - *string* `name`: (**optional**) Display name.
    - *object* `info`: (**optional**) Other information.
- *string* `expiredAt`: (**optional**) Set the expiration time in RFC 3339 format. Without this value means this user is never expired and is verified immediately.

- **Example**

    ```json
    {
        "data": {
            "account": "michael-johnson@example.com",
            "password": "p@ssw0rD",
            "name": "Michael",
            "info": {
                "firstName": "Michael",
                "lastName": "Johnson",
                "phoneNumber": "0987654321"
            }
        },
        "expiredAt": "2022-01-02T02:23:47.053Z"
    }
    ```

#### Response

- **200 OK**: The user ID. Parameters are:

    - *object* `data`:
        - *string* `userId`: The ID of the created user.

    - **Example**

        ```json
        {
            "data": {
                "userId": "1641003827053-c2e84RJO"
            }
        }
        ```

- **400 Bad Request**: the special error codes are:
    - `err_auth_user_exist`: The account has been used.
- **401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_admin_user_count"></a>User count

Get user list count.

    GET /auth/api/v1/user/count?
        account={specifiedAccount}&
        contains={word}

- *string* `account`: (**optional**) To search the specified account. This is case insensitive and excludes **contains**.
- *string* `contains`: (**optional**) To search accounts which contain the specified word. This is case insensitive.

#### Response

- **200 OK**: User list count. Parameters are:

    - *object* `data`:
        - *number* `count`: User list count.

    - **Example**

        ```json
        {
            "data": {
                "count": 2
            }
        }
        ```

- **400, 401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_admin_user_list"></a>User list

Get user list.

    GET /auth/api/v1/user/list?
        account={specifiedAccount}&
        contains={word}&
        fields={displayFields}&
        offset={offset}&
        limit={limit}&
        sort={sortKeysAndOrders}&
        format={responseFormat}

- *string* `account`: (**optional**) To search the specified account. This is case insensitive and excludes **contains**.
- *string* `contains`: (**optional**) To search accounts which contain the specified word. This is case insensitive.
- *string* `fields`: (**optional**) To display more data fields with comma separated format. **expired**, **disabled** can be used. For example, `fields=expired,disabled`.
- *number* `offset`: (**optional**) Data offset. Default is **0**.
- *number* `limit`: (**optional**) Number of items to list. **0** to list all data. Default is **100**.
- *string* `sort`: (**optional**) To sort the result. Format is `key:[asc|desc]`. The key can be **account**, **created**, **modified**, **verified**, **name**. Default is **account:asc**.
- *string* `format`: (**optional**) Response body format. Default is array in the **data** field.
    - **array**: The response body is JSON array, not an object.

#### Response

- **200 OK**: An array that contains all users' information. Parameters are:

    - *object[]* `data`:
        - *string* `userId`: User ID.
        - *string* `account`: User account.
        - *string* `createdAt`: Creation time in RFC 3339 format.
        - *string* `modifiedAt`: Modification time in RFC 3339 format.
        - *string | null* `verifiedAt`: Verification time in RFC 3339 format.
        - *string | null* `expiredAt`: (**optional**) Expiration time in RFC 3339 format.
        - *string | null* `disabledAt`: (**optional**) Disabled time in RFC 3339 format.
        - *object* `roles`: Roles.
        - *string* `name`: Display name.
        - *object* `info`: Other information.

    - **Example**

        ```json
        {
            "data": [
                {
                    "userId": "1640921188987-x51FTVPD",
                    "account": "admin@example.com",
                    "createdAt": "2021-12-31T03:26:28.987Z",
                    "modifiedAt": "2021-12-31T03:26:28.987Z",
                    "verifiedAt": "2021-12-31T03:26:28.987Z",
                    "expiredAt": null,
                    "disabledAt": null,
                    "roles": {
                        "admin": true
                    },
                    "name": "System administrator",
                    "info": {
                        "phoneNumber": "1234567890"
                    }
                },
                {
                    "userId": "1641003827053-c2e84RJO",
                    "account": "michael-johnson@example.com",
                    "created": "2022-01-01T02:23:47.053Z",
                    "modifiedAt": "2022-01-02T05:17:27.129Z",
                    "validated": "2022-01-01T02:26:52.210Z",
                    "expiredAt": null,
                    "disabledAt": null,
                    "roles": {},
                    "name": "Michael",
                    "info": {
                        "firstName": "Michael",
                        "lastName": "Johnson",
                        "phoneNumber": "0987654321"
                    }
                }
            ]
        }
        ```

    - **Example (format=`array`)**

        ```json
        [
            {
                "userId": "1640921188987-x51FTVPD",
                "account": "admin@example.com",
                "createdAt": "2021-12-31T03:26:28.987Z",
                "modifiedAt": "2021-12-31T03:26:28.987Z",
                "verifiedAt": "2021-12-31T03:26:28.987Z",
                "expiredAt": null,
                "disabledAt": null,
                "roles": {
                    "admin": true
                },
                "name": "System administrator",
                "info": {
                    "phoneNumber": "1234567890"
                }
            }
        ]
        ```

- **400, 401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_admin_user"></a>Get user information

Get the specified user information.

    GET /auth/api/v1/user/{userId}

- *string* `userId`: The specified user ID to get user information.

#### Response

- **200 OK**:

    - *object* `data`: An object that contains the user information. See [User administration APIs - User list]#get_admin_user_list.

- **400, 401, 403, 500, 503**: See [Notes]#notes.
- **404 Not Found**: The specified user does not exist.

## <a name="patch_admin_user"></a>Update user information

Update the specified user information.

    PATCH /auth/api/v1/user/{userId}

- *string* `userId`: The specified user ID to update user information.

#### Additional HTTP Headers

    Content-Type: application/json

#### Parameters

- *object* `data`: (**optional**)
    - *string* `verifiedAt`: (**optional for admin**) The validation date time in RFC 3339 format. The **expiredAt** field will be set to **null**.
    - *object* `roles`: (**optional**) Roles. The content must be booleans. Only administrators can set to roles **admin** and **service**.
    - *string* `password`: (**optional for admin**) User password.
    - *string* `name`: (**optional for admin**) The display name.
    - *object* `info`: (**optional for admin**) Other information. You must provide full of fields, or all fields will be replaced with the new value.
- *bool* `disable`: (**optional**) **true** to disable the user and **false** to enable the user. The permissions are:
    - **admin**: (all)
    - **manager**: service, user

- **Note**: You must give at least one parameter.

- **Example**

    ```json
    {
        "data": {
            "roles": {
                "developer": true
            },
            "info": {
                "firstName": "Michael",
                "lastName": "Johnson",
                "address": "123, abc road, def city",
                "phoneNumber": "123456"
            }
        },
        "disable": false
    }
    ```

#### Response

- **204 No Content**
- **400, 401, 403, 500, 503**: See [Notes]#notes.
- **404 Not Found**: The specified user does not exist.

## <a name="delete_admin_user"></a>Delete user

Delete a user. One cannot delete himself/herself.

    DELETE /auth/api/v1/user/{userId}

- *string* `userId`: The specified user ID to delete.

#### Response

- **204 No Content**
- **401, 403, 500, 503**: See [Notes]#notes.

# <a name="client"></a>Client administration APIs

These APIs can be used by system administrators and developers only, except:

- `DELETE /auth/api/v1/client/user/{userId}`: for administrators.

## <a name="post_client"></a>Create client

Create a client.

    POST /auth/api/v1/client

#### Additional HTTP Headers

    Content-Type: application/json

#### Parameters

- *object* `data`:
    - *string[]* `redirectUris`: Allowed redirect URIs.
    - *string[]* `scopes`: Allowed scopes in `[a-z0-9]+([\.]{1}[a-z0-9])*` format.
    - *string* `userId`: (**optional for administrators**) Assign to the specified user.
    - *string* `name`: Client name.
    - *string* `image`: (**optional**) The URI of the client icon.
- *boolean* `credentials`: (**optional**) Create the client with secret. Default is **false**.

#### Response

- **200 OK**: The client ID. Parameters are:

    - *object* `data`:
        - *string* `clientId`: The ID of the created client.

    - **Example**

        ```json
        {
            "data": {
                "clientId": "1641040728318-zyAnDK9I"
            }
        }
        ```

- **400 Bad Request**: the special error codes are:
    - `err_auth_user_not_exist`: The user ID does not exist.
- **401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_client_count"></a>Client count

Get client list count.

    GET /auth/api/v1/client/count?
        user={userId}

- *string* `user`: (**optional for administrators**) The specified user ID.

#### Response

- **200 OK**: Client list count. Parameters are:

    - *object* `data`:
        - *number* `count`: Client list count.

    - **Example**

        ```json
        {
            "data": {
                "count": 2
            }
        }
        ```

- **400, 401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_client_list"></a>Client list

Get client list.

    GET /auth/api/v1/client/list?
        user={userId}&
        offset={offset}&
        limit={limit}&
        sort={sortKeysAndOrders}&
        format={responseFormat}

- *string* `user`: (**optional for administrators**) The specified user ID.
- *number* `offset`: (**optional**) Data offset. Default is **0**.
- *number* `limit`: (**optional**) Number of items to list. **0** to list all data. Default is **100**.
- *string* `sort`: (**optional**) To sort the result. Format is `key:[asc|desc]`. The key can be **created**, **modified**, **name**. Default is **name:asc**.
- *string* `format`: (**optional**) Response body format. Default is array in the **data** field.
    - **array**: The response body is JSON array, not an object.

- **Note**: Administrators can get all clients and developers can only get their own clients.

#### Response

- **200 OK**: An empty array or an array that contains all clients' information. Parameters are:

    - *object* `data`:
        - *string* `clientId`: Client ID.
        - *string* `createdAt`: Creation time in RFC 3339 format.
        - *string* `modifiedAt`: Modification time in RFC 3339 format.
        - *string | null* `clientSecret`: Client secret. **null** means that this is a public client.
        - *string[]* `redirectUris`: Allowed redirect URIs.
        - *string[]* `scopes`: Allowed scopes.
        - *string* `userId`: (**optional for administrators**) User ID that is associated with the client.
        - *string* `name`: Client name.
        - *string | null* `image`: The URI of the client icon.

    - **Example**

        ```json
        {
            "data": [
                {
                    "clientId": "1641040728318-zyAnDK9I",
                    "createdAt": "2022-01-01T12:38:48.318Z",
                    "modifiedAt": "2022-01-01T12:38:48.318Z",
                    "clientSecret": "G3LCtKsJvB3nrkA4CnIH3IUVF+BKMHXHTXbzgNF6REU",
                    "redirectUris": [ "https://localhost/oauth2/desktop" ],
                    "scopes": [ "user.rw", "client.rw" ],
                    "name": "OAuth2 App",
                    "image": "https://localhost/oauth2/app.png"
                },
                {
                    "clientId": "1641042262366-1HTBqdPg",
                    "createdAt": "2022-01-01T13:04:22.366Z",
                    "modifiedAt": "2022-01-02T07:52:38.129Z",
                    "redirectUris": [ "https://exmaple.com/oauth2/redirect/uri" ],
                    "scopes": [ "user.rw", "client.rw" ],
                    "name": "OAuth2 Web",
                    "image": "https://example.com/oauth2/web.png"
                }
            ]
        }
        ```

    - **Example (format=`array`)**

        ```json
        [
            {
                "clientId": "1641040728318-zyAnDK9I",
                "createdAt": "2022-01-01T12:38:48.318Z",
                "modifiedAt": "2022-01-01T12:38:48.318Z",
                "clientSecret": "G3LCtKsJvB3nrkA4CnIH3IUVF+BKMHXHTXbzgNF6REU",
                "redirectUris": [ "https://localhost/oauth2/desktop" ],
                "scopes": [ "user.rw", "client.rw" ],
                "name": "OAuth2 App",
                "image": "https://localhost/oauth2/app.png"
            }
        ]
        ```

- **400, 401, 403, 500, 503**: See [Notes]#notes.

## <a name="get_client"></a>Get client information

Get the specified client information.

    GET /auth/api/v1/client/{clientId}

- *string* `clientId`: The specified client ID to get client information.

#### Response

- **200 OK**:

    - *object* `data`: An object that contains the client information. See [Client administration APIs - Client list]#get_client_list.

- **400, 401, 403, 500, 503**: See [Notes]#notes.
- **404 Not Found**: The specified client does not exist.

## <a name="patch_client"></a>Update client information

Update the specified client information.

    PATCH /auth/api/v1/client/{clientId}

- *string* `clientId`: The specified client ID to update client information.

#### Additional HTTP Headers

    Content-Type: application/json

#### Parameters

- *object* `data`: (**optional**)
    - *string[]* `redirectUris`: (**optional**) Allowed redirect URIs.
    - *string[]* `scopes`: (**optional**) Allowed scopes in `[a-z0-9]+([\.]{1}[a-z0-9])*` format.
    - *string* `name`: (**optional**) Client name.
    - *string | null* `image`: (**optional**) The URI of the client icon.
- *boolean* `regenSecret`: (**optional**) Re-generate secret of the private client. Default is **false**.

- **Note**: You must give at least one parameter.

- **Example**

    ```json
    {
        "data": {
            "name": "New client name"
        }
    }
    ```

#### Response

- **204 No Content**
- **400, 401, 403, 500, 503**: See [Notes]#notes.
- **404 Not Found**: The specified client does not exist.

## <a name="delete_client"></a>Delete client

Delete a client. One client cannot delete itself.

    DELETE /auth/api/v1/client/{clientId}

- *string* `clientId`: The specified client ID to delete.

#### Response

- **204 No Content**
- **400, 401, 403, 500, 503**: See [Notes]#notes.

## <a name="delete_client_user"></a>Delete user clients

Delete all clients of the specified user.

    DELETE /auth/api/v1/client/user/{userId}

- *string* `userId`: The specified user ID.

#### Response

- **204 No Content**
- **400, 401, 403, 500, 503**: See [Notes]#notes.