> For the complete documentation index, see [llms.txt](https://products.monterosa.co/mic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://products.monterosa.co/mic/developer-guide/app-specs/app-spec/external-data-source.md).

# External data source

External data source mechanism is used with fields to specify that the value for a field must be fetched from an external source.

Source is described by these properties:

| ​       | ​                                                                                                                                                                    |
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url     | Absolute or relative URL pointing to document containing the data.                                                                                                   |
| method  | HTTP method used to request data. Can be “get” or “post”.                                                                                                            |
| service | Service type, required if relative URL is specified. If set then data is provided by specified service. Service base URL is used to build full URL to data document. |

## GET <a href="#get" id="get"></a>

### external data via GET <a href="#external-data-via-get" id="external-data-via-get"></a>

```
"source": { "url": "http://example.com/external.json", "method": "get" }
```

The platform sends GET request to specified URL and expects data as a response.‌

## POST <a href="#post" id="post"></a>

### external data via POST <a href="#external-data-via-post" id="external-data-via-post"></a>

```
"source": { "url": "http://example.com/prefill.json", "method": "post" }
```

The Interaction Cloud sends POST request to specified URL with project, event (if the field attached to event or element) and element (if the field attached to element) custom fields values.‌

### Request data <a href="#request-data" id="request-data"></a>

```javascript
{
    "project_id": "605b68ae-3efd-4edd-8139-84cbbcd20b3f",
    "project": 
    {
        "custom_fields": 
        {
            "competition_id": "1234",
            "twitter_hash_tag": "#lvis"
        }
    },
    "event_id": "851193bd-095b-478f-9b94-a8d7155f2603",
    "event": 
    {
        "custom_fields": 
        {
            "channel": "c4"
        }
    },
    "element": 
    {
        "content_type": "man_of_the_match",
        "custom_fields": 
        {
            "team_id": "234",
            "podium": [{
                "id": "p1",
                "data": "payload"
            }]
        }
    }
}
```

If request can not successfully return data it should return non-200 HTTP code and a body like this:‌

### Error response body <a href="#error-response-body" id="error-response-body"></a>

```javascript
{
    "missing_fields":
    {
        "project": ["competition_id"],
        "event": ["channel_id", "twitter_hash_tag"],
        "element": ["team_id"]
    },
    "error": "Unknown match id 1234"
}
```

Both `missing_fields` and `error` are optional.‌

## POST via Service <a href="#post-via-service" id="post-via-service"></a>

```
"source": { "url": "/prefill.json", "method": "post", "service": "prefiller" }
```

Request URL is constructed as `<service base url>/prefill.json`.‌

The platform passes `instance_uuid` and `project_uuid` parameters via the query string with an instance id and project id respectively.

{% hint style="warning" %}
Is a service is used as a source, it must be specified as a required service in the app spec.
{% endhint %}


---

# 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://products.monterosa.co/mic/developer-guide/app-specs/app-spec/external-data-source.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.
