> For the complete documentation index, see [llms.txt](https://docs.agilecase.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agilecase.com/developer-documentation/case-data-api.md).

# Case Data API

The Case Data API is how a script running in the browser reads data from a case. Scripts on the case page cannot see the database directly, so anything beyond what happens to be on screen is fetched from this endpoint as JSON.

It is used by [on load scripts](/developer-documentation/case-scripting/on-load-scripts.md) and by [JavaScript label fields](/developer-documentation/custom-form-scripting.md), and it is read-only. There is no way to write data through it: changing data from a script means an [on save script](/developer-documentation/case-scripting/on-save-scripts.md).

## The endpoint

```
GET /api/case/{caseId}/data?getValues={tokens}
```

Two things are needed: the case to read from, and a list of what you want. The list goes in `getValues`, and each item names a type and a field:

```javascript
$.get('/api/case/' + caseid + '/data?getValues=Custom.CustomerRating', function (data) {
    var rating = data.data.customFields[0].value;
});
```

The `caseid` variable is already available on the case page, so you rarely need to hardcode a case ID.

You can ask for as many values as you like in one request by separating them with semicolons, which is almost always better than making several requests:

```javascript
$.get('/api/case/' + caseid + '/data?getValues=case.CaseReference;case.FeeEarner;Custom.CustomerRating',
    function (data) {
        // ...
    });
```

## Authentication and permissions

The request is authenticated by the signed-in user's own session. There is nothing to configure and no key to pass, because the browser sends the session cookie automatically. This also means the API sees exactly what that user is allowed to see: asking for a case they have no permission for returns a failure rather than the data.

The endpoint is for internal users. Client portal users have their own equivalent under `/c/{guid}/api/case/{caseId}/data`, which takes the same `getValues` list.

{% hint style="info" %}
Because this API is driven by the current user's session, it is not a general purpose integration point. It is for code running in a signed-in user's browser. A server-to-server integration should use webhooks instead.
{% endhint %}

## Where to go next

<table data-view="cards"><thead><tr><th>Page</th><th>What it covers</th><th data-card-target data-type="content-ref">Target</th></tr></thead><tbody><tr><td><strong>Requesting Values</strong></td><td>The syntax of <code>getValues</code>, and the six kinds of data you can ask for.</td><td><a href="/pages/j1JyTG1bMI5eq7djCBMP">/pages/j1JyTG1bMI5eq7djCBMP</a></td></tr><tr><td><strong>Field Reference</strong></td><td>The exact names available for case fields and contact fields.</td><td><a href="/pages/zYsLHGyyGcthViJRQ6cP">/pages/zYsLHGyyGcthViJRQ6cP</a></td></tr><tr><td><strong>Response Format</strong></td><td>The shape of the JSON that comes back, and how errors are reported.</td><td><a href="/pages/enVZYo0uDG8MTSFq2Hzt">/pages/enVZYo0uDG8MTSFq2Hzt</a></td></tr></tbody></table>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.agilecase.com/developer-documentation/case-data-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
