Site Routes

Get a Site’s Routes

GET /sites/{site_id}/routes

Request

Get a site’s routes.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - integer
    required
  • type in query - string
    Filter routes by a specified resource type.
  • page in query - integer
    Specifies the page number in a limited (paginated) list of items.
  • limit in query - integer
    Controls the number of items per page in a limited (paginated) list of items.

example

curl --request GET \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/sites/[site_id]/routes' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

Body

object | application/json
  • data
    array[object]

  • meta
    object

    Meta data relating to pagination.

response

{
"data": [
{
"id": 1,
"type": "product",
"matching": "5",
"route": "/products?id={id}"
},
{
"id": 2,
"type": "category",
"matching": "44",
"route": "/category/{slug}"
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 50,
"current_page": 1,
"total_pages": 1
}
}
}

Create a Site Route

POST /sites/{site_id}/routes

Request

Create routes that tell BigCommerce how to link to pages on a headless storefront.

Usage Notes

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - integer
    required
  • Content-Type in header with default of application/json - string
    required
    The MIME type of the request body.

Body

object | application/json
  • type
    string

    The type of resource being routed to; supported types.

    Allowed: product | brand | category | page | blog | home | cart | checkout | search | account | login | returns | static

  • matching
    string

    Depending on the resource type, this can be an ID (matching a specific item), or a "*" wildcard (matching all items of that type).

    For example, a route with a type: "product" and matching: "5" will be used for the product with the ID of 5.

    Example: 5
  • route
    string

    The route template that will be used to generate the URL for the requested resource.

    Supports several tokens:

    • {id} The ID of the requested item.
    • {slug} The slug for the requested item (if available). Note: the slug value may contain / slash.
    • {language} The language string that the client is using.
    Example: /my-amazing-product

example

{
"type": "product",
"matching": "5",
"route": "/my-amazing-product"
}

Response

Body

object | application/json
  • data
    object

    Route object used in responses.
  • meta
    object

    Response metadata.

response

{
"data": {
"id": 123,
"type": "checkout",
"matching": "5",
"route": "/my-amazing-product"
},
"meta": {}
}

Update a Site’s Routes

PUT /sites/{site_id}/routes

Request

Upsert routes for site with ID {site_id}.

Usage Notes

  • id is required when updating an existing route.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - integer
    required
  • Content-Type in header with default of application/json - string
    required
    The MIME type of the request body.

Body

array | application/json
  • id
    integer

    Unique ID for this route. Required when updating an existing route.
  • type
    string

    The type of resource being routed to; supported types.

    Allowed: product | brand | category | page | blog | home | cart | checkout | search | account | login | returns | static

  • matching
    string

    Depending on the resource type, this can be an ID (matching a specific item), or a "*" wildcard (matching all items of that type).

    For example, a route with a type: "product" and matching: "5" will be used for the product with the ID of 5.

    Example: 5
  • route
    string

    The route template that will be used to generate the URL for the requested resource.

    Supports several tokens:

    • {id} The ID of the requested item.
    • {slug} The slug for the requested item (if available). Note: the slug value may contain / slash.
    • {language} The language string that the client is using.
    Example: /my-amazing-product

example

[
{
"id": 0,
"type": "product",
"matching": "5",
"route": "/my-amazing-product"
}
]

Response

Body

object | application/json
  • data
    array[object]

  • meta
    object

    Meta data relating to pagination.

response

{
"data": [
{
"id": 123,
"type": "brand",
"matching": "5",
"route": "/my-amazing-product"
},
{
"id": 345,
"type": "blog",
"matching": "5",
"route": "/my-amazing-product"
},
{
"id": 234,
"type": "returns",
"matching": "5",
"route": "/my-amazing-product"
}
],
"meta": {
"pagination": {
"total": 80,
"count": 50,
"per_page": 50,
"current_page": 50,
"total_pages": 2,
"links": {
"current": "?page=1&limit=50",
"next": "?page=2&limit=50"

Get a Site Route

GET /sites/{site_id}/routes/{route_id}

Request

Get a site’s route.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - string
    required
  • route_id in path - string
    required

example

curl --request GET \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/sites/[site_id]/routes/[route_id]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

Body

object | application/json
  • data
    object

    Route object used in responses.
  • meta
    object

    Response metadata.

response

{
"data": {
"id": 60474753,
"type": "checkout",
"matching": "5",
"route": "/my-amazing-product"
},
"meta": {}
}

Update a Site Route

PUT /sites/{site_id}/routes/{route_id}

Request

Update a site’s route.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - string
    required
  • route_id in path - string
    required
  • Content-Type in header with default of application/json - string
    required
    The MIME type of the request body.

Body

object | application/json
  • type
    string
    required

    The type of resource being routed to; supported types.

    Allowed: product | brand | category | page | blog | home | cart | checkout | search | account | login | returns | static

  • matching
    string
    required

    Depending on the resource type, this can be an ID (matching a specific item), or a "*" wildcard (matching all items of that type).

    For example, a route with a type: "product" and matching: "5" will be used for the product with the ID of 5.

    Example: 5
  • route
    string
    required

    The route template that will be used to generate the URL for the requested resource.

    Supports several tokens:

    • {id} The ID of the requested item.
    • {slug} The slug for the requested item (if available). Note: the slug value may contain / slash.
    • {language} The language string that the client is using.
    Example: /my-amazing-product

example

{
"type": "product",
"matching": "5",
"route": "/my-amazing-product"
}

Response

Body

object | application/json
  • data
    object

    Route object used in responses.
  • meta
    object

    Response metadata.

response

{
"data": {
"id": 123,
"type": "checkout",
"matching": "5",
"route": "/my-amazing-product"
},
"meta": {}
}

Delete a Site Route

DELETE /sites/{site_id}/routes/{route_id}

Request

Delete a site’s route.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • site_id in path - string
    required
  • route_id in path - string
    required

example

curl --request DELETE \
--url 'https://api.bigcommerce.com/stores/[store_hash]/v3/sites/[site_id]/routes/[route_id]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: {{token}}'

Response

Did you find what you were looking for?