Elements

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
POST
GET
PATCH
DELETE
GET
GET

List all elements

Required API key scopes

element:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/elements
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}
]
}

Create elements

Required API key scopes

element:write

Request parameters

  • text
    string | null
  • tag_name
    string | null
  • attr_class
    array | null
  • href
    string | null
  • attr_id
    string | null
  • nth_child
    integer | null
  • nth_of_type
    integer | null
  • attributes
  • order
    integer | null

Response


Example request

POST /api/projects/:project_id/elements
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/\
-d text="string"

Example response

Status 201
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Retrieve elements

Required API key scopes

element:read

Path parameters

  • id
    integer

Response


Example request

GET /api/projects/:project_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/:id/

Example response

Status 200
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Update elements

Required API key scopes

element:write

Path parameters

  • id
    integer

Request parameters

  • text
    string | null
  • tag_name
    string | null
  • attr_class
    array | null
  • href
    string | null
  • attr_id
    string | null
  • nth_child
    integer | null
  • nth_of_type
    integer | null
  • attributes
  • order
    integer | null

Response


Example request

PATCH /api/projects/:project_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/:id/\
-d text="string"

Example response

Status 200
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Delete elements

Required API key scopes

element:write

Path parameters

  • id
    integer

Example request

DELETE /api/projects/:project_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/:id/

Example response

Status 204 No response body

Retrieve elements stats

Counts of $autocapture, $rageclick, and $dead_click events grouped by the element chain they occurred on, ordered by count. Defaults to all three event types; narrow with the include parameter.

Required API key scopes

element:read

Query parameters

  • data_attributes
    string
  • date_from
    string
  • date_to
    string
  • filter_test_accounts
    boolean
  • include
    array
  • limit
    integer
  • offset
    integer
  • properties
    string
  • sampling_factor
    number

Response


Example request

GET /api/projects/:project_id/elements/stats
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/stats/

Example response

Status 200
RESPONSE
{
"results": [
{
"count": 0,
"hash": "string",
"type": "string",
"elements": [
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}
]
}
],
"next": "string",
"previous": "string"
}

List all elements values

Required API key scopes

element:read

Query parameters

  • key
    string
  • value
    string

Example request

GET /api/projects/:project_id/elements/values
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/elements/values/

Example response

Status 200
RESPONSE
{
"name": "string"
}