You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sites-api.md
+187-1Lines changed: 187 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ import {Required, Optional} from '../src/js/api-helpers.tsx';
7
7
The Plausible Site provisioning API offers a way to create and manage sites in your Plausible account programmatically. This is useful if you run many websites or if you're [offering a web analytics dashboard powered by Plausible to your customers](https://plausible.io/white-label-web-analytics). The Site API allows these operations:
8
8
9
9
* List existing sites
10
+
* List teams
10
11
* Create a new site
11
12
* Delete an existing site
12
13
* Change a domain name
@@ -15,6 +16,9 @@ The Plausible Site provisioning API offers a way to create and manage sites in y
15
16
* List existing goals
16
17
* Find or create a goal by type and value (learn more about [goals and custom events](goal-conversions.md))
17
18
* Delete an existing goal
19
+
* List site guests/invitations
20
+
* Create site guest invitations
21
+
* Delete site guests/invitations
18
22
19
23
Each request must be authenticated with an API key using the Bearer Token method. Please [contact us](https://plausible.io/contact) to discuss your needs and to get an API key with permissions for the endpoints listed in this document.
20
24
@@ -72,7 +76,69 @@ Pagination cursor. See [Pagination](#pagination).
72
76
73
77
Pagination limit. Defaults to 100. See [Pagination](#pagination).
74
78
79
+
**team_id** <Optional />
80
+
81
+
ID of the team to scope the list of sites by. All sites including the ones accessible via guest membership are listed when no ID provided.
82
+
83
+
<hr / >
84
+
85
+
### GET /api/v1/sites/teams
86
+
87
+
Gets a list of teams your Plausible account can access. The `api_available` attribute determines if the API is available for a given team.
88
+
89
+
```bash title="Try it yourself"
90
+
curl -X GET https://plausible.io/api/v1/sites/teams \
91
+
-H "Authorization: Bearer ${TOKEN}"
92
+
```
93
+
94
+
```json title="Response 200 OK"
95
+
{
96
+
"teams": [
97
+
{
98
+
"id": "4d3dae3b-2a44-4aaa-baac-6bb55234a435",
99
+
"name": "My Personal Sites",
100
+
"api_available": false,
101
+
},
102
+
{
103
+
"id": "ef828bca-8a1b-49f6-b829-dee1c9f7d628",
104
+
"name": "Some Team",
105
+
"api_available": true,
106
+
},
107
+
{
108
+
"id": "59e4d5b3-fc1c-464d-95f2-dbe6983396be",
109
+
"name": "Another Team",
110
+
"api_available": true,
111
+
}
112
+
],
113
+
"meta": {
114
+
"after": null,
115
+
"before": null,
116
+
"limit": 100
117
+
}
118
+
}
119
+
```
120
+
121
+
#### Query parameters
122
+
<hr / >
123
+
124
+
**after** <Optional />
125
+
126
+
Pagination cursor. See [Pagination](#pagination).
127
+
75
128
<hr / >
129
+
130
+
**before** <Optional />
131
+
132
+
Pagination cursor. See [Pagination](#pagination).
133
+
134
+
<hr / >
135
+
136
+
**limit** <Optional />
137
+
138
+
Pagination limit. Defaults to 100. See [Pagination](#pagination).
139
+
140
+
<hr / >
141
+
76
142
### POST /api/v1/sites
77
143
78
144
Creates a site in your Plausible account.
@@ -104,6 +170,12 @@ Domain of the site to be created in Plausible. Must be a globally unique, the re
104
170
Timezone name according to the [IANA](https://www.iana.org/time-zones) database. Defaults to `Etc/UTC` when left blank.
105
171
<hr / >
106
172
173
+
**team_id** <Optional />
174
+
175
+
ID of the team under which the created site is to be put. Defaults to the ID of "My Personal Sites".
176
+
177
+
<hr / >
178
+
107
179
### PUT /api/v1/sites/:site_id
108
180
109
181
Update an existing site in your Plausible account. Note: currently only `domain` change is allowed.
@@ -131,7 +203,7 @@ Domain of the site to be created in Plausible. Must be a globally unique, the re
131
203
132
204
### DELETE /api/v1/sites/:site_id
133
205
134
-
Deletes a site from your Plausible account along with all it's data and configuration. The API key must belong to the owner of the site.
206
+
Deletes a site from your Plausible account along with all its data and configuration. The API key must belong to the owner of the site.
135
207
Permanently deleting all your data may take up to 48 hours and you won't be able to immediately register the same site again until the process is complete.
136
208
137
209
```bash title="Try it yourself"
@@ -338,6 +410,120 @@ Id of your site in Plausible.
338
410
339
411
<hr / >
340
412
413
+
### GET /api/v1/sites/guests
414
+
415
+
Gets a list of guests for a given `site_id` (use the site domain as the ID).
416
+
417
+
```bash title="Try it yourself"
418
+
curl -X GET https://plausible.io/api/v1/sites/guests?site_id=test-domain.com \
419
+
-H "Authorization: Bearer ${TOKEN}"
420
+
```
421
+
422
+
```json title="Response 200 OK"
423
+
{
424
+
"guests": [
425
+
{
426
+
"email": "alice@example.com",
427
+
"role": "viewer",
428
+
"status": "accepted"
429
+
},
430
+
{
431
+
"email": "bob@example.com",
432
+
"role": "editor",
433
+
"status": "invited"
434
+
}
435
+
],
436
+
"meta": {
437
+
"after": null,
438
+
"before": null,
439
+
"limit": 100
440
+
}
441
+
}
442
+
```
443
+
444
+
445
+
#### Query parameters
446
+
<hr / >
447
+
448
+
**site_id** <Required />
449
+
450
+
Id of your site in Plausible.
451
+
452
+
<hr / >
453
+
454
+
**after** <Optional />
455
+
456
+
Pagination cursor. See [Pagination](#pagination).
457
+
458
+
<hr / >
459
+
460
+
**before** <Optional />
461
+
462
+
Pagination cursor. See [Pagination](#pagination).
463
+
464
+
<hr / >
465
+
466
+
**limit** <Optional />
467
+
468
+
Pagination limit. Defaults to 100. See [Pagination](#pagination).
469
+
470
+
<hr / >
471
+
472
+
### PUT /api/v1/sites/guests
473
+
474
+
For a given `site_id` (use the site domain as the ID), finds an invitation or existing guest membership or sends a new invitation to a given `email`. This endpoint is idempotent, it won't fail if guest/invitation with the provided e-mail already exists.
475
+
476
+
477
+
```bash title="Try it yourself"
478
+
curl -X PUT https://plausible.io/api/v1/sites/guests \
479
+
-H "Authorization: Bearer ${TOKEN}" \
480
+
-F 'site_id="test-domain.com"' \
481
+
-F 'role="viewer"' \
482
+
-F 'email="alice@example.com"'
483
+
```
484
+
485
+
```json title="Response 200 OK"
486
+
{
487
+
"email": "alice@example.com",
488
+
"role": "viewer",
489
+
"status": "invited"
490
+
}
491
+
```
492
+
493
+
#### Body parameters
494
+
<hr / >
495
+
496
+
**site_id**<Required />
497
+
498
+
Id of your site in Plausible.
499
+
500
+
<hr / >
501
+
502
+
**email**<Required />
503
+
504
+
Guest's e-mail address.
505
+
506
+
**role** <Required />
507
+
508
+
Either `editor` or `viewer`.
509
+
510
+
<hr / >
511
+
512
+
### DELETE /api/v1/sites/guests/:email
513
+
514
+
Deletes an invitation or guest membership from the given site. Does not delete associated user account, if any.
All list endpoints implement cursor based pagination. They accept following URL query parameters: `before`, `after` and `limit`. The response payload always contains pagination metadata under `meta`:
0 commit comments