diff --git a/docs/sites-api.md b/docs/sites-api.md index a26740ac..b9bc7e8f 100644 --- a/docs/sites-api.md +++ b/docs/sites-api.md @@ -16,6 +16,9 @@ The Plausible Site provisioning API offers a way to create and manage sites in y * List existing goals * Find or create a goal by type and value (learn more about [goals and custom events](goal-conversions.md)) * Delete an existing goal +* List existing custom properties +* Create a custom property +* Delete an existing custom property * List site guests/invitations * Create site guest invitations * Delete site guests/invitations @@ -418,6 +421,94 @@ Id of your site in Plausible.
+### GET /api/v1/sites/custom-props + +Gets a list of existing custom properties for a given `site_id` (use the site domain as the ID). + +```bash title="Try it yourself" +curl -X GET https://plausible.io/api/v1/sites/custom-props?site_id=test-domain.com \ + -H "Authorization: Bearer ${TOKEN}" +``` + +```json title="Response 200 OK" +{ + "custom_properties": [ + { + "property": "author" + }, + { + "property": "title" + } + ] +} +``` + +#### Query parameters +
+ +**site_id** + +Id of your site in Plausible. + +
+ +### PUT /api/v1/sites/custom-props + +Creates a custom property for a given `site_id` (use the site domain as the ID). This endpoint is idempotent, it won't fail if a custom property with the provided name already exists. + +```bash title="Try it yourself" +curl -X PUT https://plausible.io/api/v1/sites/custom-props \ + -H "Authorization: Bearer ${TOKEN}" \ + -F 'site_id="test-domain.com"' \ + -F 'property="title"' +``` + +```json title="Response 200 OK" +{ + "created": true +} +``` + +#### Body parameters +
+ +**site_id** + +Id of your site in Plausible. + +
+ +**property** + +Name of the custom property + +
+ +### DELETE /api/v1/sites/custom-props/:property + +Deletes a custom property from your Plausible account. The API key must belong to the owner of the site. The site must owned by the current user. + +```bash title="Try it yourself" +curl -X DELETE https://plausible.io/api/v1/sites/custom-props/title \ + -H "Authorization: Bearer ${TOKEN}" \ + -F 'site_id="test-domain.com"' +``` + +```json title="Response 200 OK" +{ + "deleted": true +} +``` + +#### Body parameters +
+ +**site_id** + +Id of your site in Plausible. + +
+ ### GET /api/v1/sites/guests Gets a list of guests for a given `site_id` (use the site domain as the ID).