Skip to main content

API Detailed Explanation

Detailed Explanation of CRUD Operations.

Updated over 2 months ago

Create a New Page

Endpoint: POST /api/admin/{workspace_id}/templates/{campaign_id}/pages

Creates a new page associated with a specific template.

Copy the URL Endpoint from the "Clay" tab within the ABM Modal. You can access it from the Editor navbar Settings button.

Headers

{ "Accept": "application/json", "Authorization": "Bearer {access_token}"}

Request Body

{
"slug": "slug-is-required-in-create-and-update-requests",
"variable_one": "Updated Company",
"variable_two": "Updated brief description."
}

Sample Responses

201 Created

{
"data": {
"slug": "draft-4/slug-is-required-in-create-and-update-requests",
"variable": {
"variables": {
"slug": "slug-is-required-in-create-and-update-requests",
"variable_one": "Updated Company",
"variable_two": "Updated brief description."
}
},
"url": "https://example.com/custom-page-slug"
}
}

422 Validation Error

{
"message": "The given data was invalid.",
"errors": {
"slug": [
"The slug must contain only letters, numbers and dashes."
]
}
}

400 Bad Request

(e.g., Default Template Modification)

{
"error": "You cannot modify pages of default template"
}

Retrieve Pages for a Template

Endpoint: GET /api/admin/{workspace_id}/templates/{campaign_id}/pages

Fetches a list of pages belonging to a specific template. This list has pagination.

Headers

{
"Accept": "application/json",
"Authorization": "Bearer {access_token}"
}

Query Parameters

Name

Type

Required

Description

Example

sort

string

Optional

Sort by fields. Available values: slug, created_at, updated_at, status. Use - for descending.

sort=-created_at

filter[status]

string

Optional

Filter by status: draft, published.

filter[status]=draft

filter[search]

string

Optional

Search by slug. Matches strings starting with the input.

filter[search]=slug

include

string

Optional

Include relationships to the response. Accepted values: variable,.

include=variable

page[number]

int

Optional

The page number to retrieve. Defaults to the first page if not specified.

page[number]=2

page[size]

int

Optional

The number of items per page. Defaults to a predefined value on the server (e.g., 15 or 20, max is 250).

page[size]=10

Sample Responses

200 OK

{
"data": [
{
"id": 1,
"slug": "custom-page-slug",
"status": "published",
"created_at": "2023-10-01T10:00:00Z",
"updated_at": "2023-10-02T10:00:00Z",
"url": "https://example.com/custom-page-slug"
}
],
"template": {
"id": 10,
"name": "Marketing Template"
},
"meta": {
"current_page": 2,
"from": 11,
"last_page": 5,
"path": "http://example.com/api/pages",
"per_page": 10,
"to": 20,
"total": 50
}
}

Update an Existing Page

Endpoint PUT /api/admin/{workspace_id}/templates/{campaign_id}/pages/{page_id}

Updates an existing page associated with a template.

Headers

{
"Accept": "application/json",
"Authorization": "Bearer {access_token}"
}

Request Body

{
"slug": "slug is always required but in this endpoint you can update it",
"variable_one": "Updated Company",
"variable_two": "Updated brief description."
}

Sample Responses

200 OK

{
"data": {
"variable": {
"variables": {
"slug": "slug is always required but in this endpoint you can update it",
"variable_one": "Updated Company",
"variable_two": "Updated brief description."
}
},
"url": "https://example.com/updated-company",
"slug": "full slug with campaign prefix"
}
}

404 Not Found

(Non-existent Page)

{
"message": "Resource not found."
}

Delete a Page

Endpoint: DELETE /api/admin/{workspace_id}/templates/{campaign_id}/pages/{page_id}

Deletes a page associated with a given template.

Headers

  • Accept: application/json

  • Authorization: Bearer {access_token}

Responses

204 No Content

{
"message": "The page has been deleted successfully."
}

404 Not Found

{
"message": "The page does not exist in this template."
}

5. Delete All Pages for a Template

Endpoint: DELETE /api/admin/{workspace_id}/templates/{campaign_id}/pages/{page_id}

This endpoint allows the deletion of all pages associated with a specific template. Be cautious as this action is irreversible, and all pages tied to the selected template will be permanently removed.

Headers

{
"Accept": "application/json",
"Authorization": "Bearer {access_token}"
}

Operation Details

  • Templates marked as the default template cannot have their pages deleted. An attempt to do so will return a 400 Bad Request.

  • Any associated page analytics will be updated to reflect a reset in the page count if applicable.

Responses

204 No Content

{
"message": "All pages deleted."
}

Error Responses

400 Bad Request

Occurs when attempting to delete pages from a default template.

{
"error": "You cannot modify pages of default template"
}

404 Not Found

Occurs when the specified workspace_id, campaign_id, or page_id does not exist.

{
"message": "Resource not found."
}
Did this answer your question?