> For the complete documentation index, see [llms.txt](https://learn.mechanic.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.mechanic.dev/platform/cache/endpoints.md).

# Cache endpoints

Cache endpoints are private JSON APIs for accessing data from the Mechanic [**cache**](/platform/cache.md). Like [webhooks](/platform/webhooks.md), cache endpoints may be called from a Shopify online storefront (and from other origins). This makes for a flexible way to generate, collect, or transform data into something you can pull in to your online customer experiences.

Combining webhooks with cache endpoints creates a closed loop: webhooks receive data for processing, and cache endpoints can return data once processed.

Mechanic's cache endpoints include CORS support for all origins, making these requests available for use in online user experiences.

## Configuration

Cache endpoints may be configured in the Mechanic settings:

<figure><img src="https://3145272362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQrnkixbmVHvKHMwAbm%2Fuploads%2Fgit-blob-6501b3aa7e76b4276cd30ca034cbdc71720d7e1c%2Fmechanic-cache-endpoints.png?alt=media" alt="The Cache endpoints section in Mechanic settings"><figcaption></figcaption></figure>

Enter the cache key, where the desired data has been stored, and save to receive a unique cache endpoint URL. The URL, when accessed, will return a JSON response containing the value associated with that cache key.

### Alternatives

Not all data can be JSON-encoded. To work around this restriction, use the [base64](/platform/liquid/filters.md#base-64-decode_base64) Liquid filter to cache base64-encoded data.

Values cached in Mechanic have a maximum lifetime of 60 days. If data must be stored long-term, or is quite large, consider using the [FTP](/core/actions/ftp.md) action in concert with a service like [Couchdrop](https://couchdrop.io/), to send data to a more appropriate storage location.

## Usage

Data for a cache endpoint must be populated using the [Cache action](/core/actions/cache.md).

Data from a cache endpoint may be requested in any context. Here's an example, using fetch:

```javascript
fetch('https://usemechanic.com/cache/0000-0000')
  .then(response => response.json())
  .then(data => console.log('Received data from cache endpoint', data));
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://learn.mechanic.dev/platform/cache/endpoints.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
