<!-- https://developers.silktide.com/v1/presence/answers/get-answers | Presence / Answers -->

# Get answers in full, with their text, mentions and sources

`GET /v1/results/accounts/presence/answers`

Returns every answer assistants gave, in full: the text, the brands it mentions and the pages it cites. Use it to keep a copy of your answers in your own database, as [Load Presence into a warehouse](https://developers.silktide.com/guides/load-presence-into-a-warehouse.md) does. To list answers without their text, or only those that cite a site, use [List answers](https://developers.silktide.com/v1/presence/answers/get-responses.md).

Send `marketId` for one market, or `workspaceId` for every market the API key's user can see. Someone who can see only some of an account's markets gets only those markets' answers.

## Reading every answer

Answers come a page at a time, up to 200. When `nextAfter` is not null, send the same request with `after` set to it, until it is null. Each answer comes once.

The first request settles the dates. With `after`, `from` and `to` are ignored, so answers that arrive while you read do not move the pages. Pages are grouped by topic and oldest first within a topic, so do not expect one run of dates across them.

Read one page after another, and stay within the [rate limit](https://developers.silktide.com/v1/concepts/rate-limits.md). A page of 200 is often more than a megabyte.

## Keeping your copy up to date

Save each answer under its `responseId`, replacing the one you have. Then read recent days again on each run:

- An answer can arrive hours after it was asked for, and keeps the time it was asked for as `requestedAt`.
- Its mentions can be worked out again later, which gives them new `mentionId`s. Replace an answer's mentions and sources together, rather than one at a time.
- An answer can be removed. It stops being returned, so replace a whole day rather than only adding to it.

`topicName`, `marketIds`, `region`, `brandId` and the names of brands are as they are now, not as they were when the answer was given.

## Matching Silktide's figures

Reports in Silktide leave out some of what is here:

- They count `ok` and `not_shown` answers, and leave out `unavailable` and `failed`, when nothing was measured.
- They leave out mentions with a `relevance` of `0` when they work out sentiment, and anything named in a search engine's results page.
- They rank only the brands you track. `position` here is the place among every name in the answer.
- They count a source only when `cited` is true. Only some assistants say what they read and did not cite. For the rest, every source is one the answer cites.

Fact checks have no topic. Ask for them with `arena=fact`. In a market, they are those about the brands in that market, whether yours or a competitor. Fact checks of a fact that has been deleted for good are only in a read of the whole account.

## Request

### Query parameters

- `marketId` (integer, optional, at least 1): Only this market: the number after `/presence/` in the market's address in Silktide. Needed unless you send `workspaceId`.
- `workspaceId` (integer, optional, at least 1): Every market the API key's user can see, when sent without `marketId`. [Get the workspace](https://developers.silktide.com/v1/presence/setup/get-workspace.md) answers with it.
- `from` (integer, optional): Only answers asked for at or after this time, in Unix seconds. Defaults to 30 days before `to`.
- `to` (integer, optional): Only answers asked for at or before this time, in Unix seconds. Defaults to now.
- `platforms` (string, optional): Only these assistants, by id, comma-separated, such as `chatgpt,gemini`. Left out, all of them. An unknown id matches nothing.
- `topics` (string, optional): Only these topics, by id, comma-separated. Left out, all of them.
- `regions` (string, optional): Only these regions, by `regionId`, comma-separated. Left out, all of them.
- `prompt` (integer, optional, at least 1): Only answers to this prompt, by id.
- `arena` (string, optional): Which prompts' answers to read: `market` for prompts about a subject, `reputation` for prompts about a brand itself, `all` for both, or `fact` for fact checks, which the others leave out. Defaults to `all`. One of: `all`, `market`, `reputation`, `fact`.
- `statuses` (string, optional): Only answers with these statuses, comma-separated: `ok`, `not_shown`, `unavailable`, `failed`. Left out, all four.
- `limit` (integer, optional, 1 to 200): How many answers to return, up to `200`. Defaults to `100`.
- `after` (string, optional): Where to carry on from: the `nextAfter` of the last answers you read. Send it as it came, with everything else unchanged.

## Response

Status `200`.

- `result` (object, required): The answer.
  - `workspaceId` (integer, required, at least 1): Where the account's markets live.
  - `from` (integer, required): The first moment read.
  - `to` (integer, required): The last moment read.
  - `limit` (integer, required, 1 to 200): The most answers this could return.
  - `responses` (list of objects, required): The answers, one per response, grouped by topic, oldest first within each.
    - `responseId` (integer, required, at least 1): The answer: one prompt put to one assistant, once. Save each answer under this id.
    - `promptId` (integer, required, at least 1): The prompt.
    - `promptText` (string, required): The prompt, as it was put to this assistant.
    - `topicId` (integer, required, can be null, at least 1): The prompt's topic. Null for a fact check.
    - `topicName` (string, required, can be null): The topic's name now. Null for a fact check.
    - `workspaceId` (integer, required, at least 1): Where the account's markets live.
    - `marketIds` (list of integers, required): The markets the prompt's topic is in now, of those the API key's user can see. A topic can be in several. Empty for a fact check.
    - `arena` (string, required, can be null): What the prompt was about: `market` for a subject, `reputation` for a brand itself, or `fact` for a fact check. Null for some answers from before this was recorded. One of: `market`, `reputation`, `fact`.
    - `region` (object, required, can be null): Where and in which language the prompt was asked. Null when the region no longer exists.
      - `regionId` (integer, required, at least 1): The region.
      - `name` (string, required): The region's name.
      - `countryCode` (string, required): The country, as two letters: `US`.
      - `stateCode` (string, required): The state or subdivision, such as `TX`. Empty for a whole country.
      - `language` (string, required): The language the prompt was asked in, such as `en-US`.
    - `requestedAt` (integer, required): When the answer was asked for. Prompts asked together share it. The answer may have come hours later.
    - `platformId` (string, required): The assistant, by id, such as `chatgpt`.
    - `model` (string, required): The model that answered, where the assistant says which. Otherwise empty.
    - `status` (string, required): `ok` when the assistant answered, `not_shown` when it showed no answer to this prompt, `unavailable` when its service returned nothing usable, or `failed`. One of: `ok`, `not_shown`, `unavailable`, `failed`.
    - `error` (string, required, can be null): Why there is no answer, in words. Null when there is one, or no more to say.
    - `truncated` (boolean, required): Whether the assistant stopped before it had finished, so the answer is cut short.
    - `answer` (string, required, can be null): The whole answer, as Markdown. Null when there is none.
    - `mentions` (list of objects, required): Every name of a brand, company or product in the answer, in the order it names them.
      - `mentionId` (integer, required, at least 1): The mention.
      - `surfaceText` (string, required): The name as the answer wrote it.
      - `position` (integer, required): Where the name comes among every name in the answer, from `1`. Counts names you do not track too.
      - `portrayal` (string, required): How the answer speaks of it: praised, both praised and criticized, neither, or criticized. One of: `positive`, `mixed`, `neutral`, `negative`.
      - `quotes` (list of objects, required): The parts of the answer that praise or criticize it. Up to three of each. Often empty.
        - `text` (string, required): The words, exactly as the answer has them.
        - `tone` (string, required): Whether they praise or criticize. One of: `praise`, `criticism`.
        - `superlative` (boolean, required): Whether they call it the best, or the worst, outright.
      - `relevance` (integer, required, 0 to 2): `2` when the answer offers it as an answer to the prompt, `1` when it is connected to the prompt but not offered, `0` when it is only named in passing.
      - `entityId` (integer, required, can be null, at least 1): The company, product or other thing named. The same id wherever it is named. Null when it was not identified.
      - `brandId` (integer, required, can be null, at least 1): The brand you track that this is. Null when you do not track it.
      - `url` (string, required): Its website. Empty when not known.
      - `name` (string, required): Its name, whichever way this answer wrote it.
      - `brandName` (string, required, can be null): The name of the brand you track. Null when you do not track it.
    - `sources` (list of objects, required): The pages behind the answer: those it cites, in order, then any it read and did not cite.
      - `sourceId` (integer, required, at least 1): The source.
      - `url` (string, required): The page.
      - `host` (string, required): The page's host, such as `blog.fakewinebarrel.com`.
      - `domain` (string, required): The domain the host is under, such as `fakewinebarrel.com`.
      - `title` (string, required): The page's title, as the assistant gave it. Empty when it gave none.
      - `position` (integer, required): Where the page comes among those the answer cites, from `1`. `0` for a page it did not cite.
      - `cited` (boolean, required): Whether the answer cites the page. False when the assistant read it and did not cite it.
  - `nextAfter` (string, required, can be null): What to send as `after` to carry on. Null when there are no more.
- `selector` (string, required): The query that answered, as its path: `/v1/results/scores`.
- `duration` (number, required): Seconds Silktide took to answer.

## Errors

| Status | Type | When |
| --- | --- | --- |
| 200 | `InvalidRequest` | Neither `marketId` nor `workspaceId` was sent. The error's own `status` is `400` and `properties.field` is `marketId`. The body is an error despite the status. |
| 200 | `InvalidRequest` | `limit` is not a whole number from 1 to 200. The error's own `status` is `400` and `properties.field` is `limit`. The body is an error despite the status. |
| 200 | `InvalidRequest` | `after` is not a `nextAfter` this query sent. Another argument it cannot read is named in the same way. The error's own `status` is `400` and `properties.field` is `after`. The body is an error despite the status. |
| 200 | `AccessDenied` | No such workspace or market exists in the account, or the API key's user cannot see it. Its `status` is `403`. The body is an error despite the status. |
| 200 | `EditionNotAvailable` | The account does not have Silktide 5. Its `status` is `403`. The body is an error despite the status. |
| 401 | `NotLoggedIn` | No API key was sent, or it is not a key for this region. |
| 429 | `TooManyRequests` | Too many requests to this path in five seconds. Retry after the number of seconds in the `Retry-After` header, which `properties.retryAfter` repeats. |
| 503 | - | Silktide is busy. Retry after the number of seconds in the `Retry-After` header. |

## Access

- Permission: Can see this market
- Plan feature: none
- Edition: Silktide 5 only
- Cost: free
- Stability: stable, since 1.2.0

## Example: One day's answers in one market

```bash
curl "https://api.eu.silktide.com/v1/results/accounts/presence/answers?marketId=3&from=1793577600&to=1793663999&limit=1" \
  -H "Authorization: silktide token=$SILKTIDE_API_KEY"
```

Response:

```json
{
  "result": {
    "workspaceId": 1,
    "from": 1793577600,
    "to": 1793663999,
    "limit": 1,
    "responses": [
      {
        "responseId": 83810,
        "promptId": 12,
        "promptText": "Who sells used oak barrels to small wineries?",
        "topicId": 7,
        "topicName": "Used barrels",
        "workspaceId": 1,
        "marketIds": [
          3
        ],
        "arena": "market",
        "region": {
          "regionId": 2,
          "name": "United States",
          "countryCode": "US",
          "stateCode": "",
          "language": "en-US"
        },
        "requestedAt": 1793610000,
        "platformId": "gemini",
        "model": "",
        "status": "ok",
        "error": null,
        "truncated": false,
        "answer": "Small wineries usually buy from one of these:\n\n1. **Fake Wine Barrel** is the best choice for small orders [1].\n2. **Example Cooperage** sells by the truckload.",
        "mentions": [
          {
            "mentionId": 410221,
            "surfaceText": "Fake Wine Barrel",
            "position": 1,
            "portrayal": "positive",
            "quotes": [
              {
                "text": "the best choice for small orders",
                "tone": "praise",
                "superlative": true
              }
            ],
            "relevance": 2,
            "entityId": 91,
            "brandId": 4,
            "url": "https://fakewinebarrel.com/",
            "name": "Fake Wine Barrel",
            "brandName": "Fake Wine Barrel"
          },
          {
            "mentionId": 410222,
            "surfaceText": "Example Cooperage",
            "position": 2,
            "portrayal": "neutral",
            "quotes": [],
            "relevance": 2,
            "entityId": 137,
            "brandId": null,
            "url": "",
            "name": "Example Cooperage",
            "brandName": null
          }
        ],
        "sources": [
          {
            "sourceId": 902114,
            "url": "https://blog.fakewinebarrel.com/buying-used",
            "host": "blog.fakewinebarrel.com",
            "domain": "fakewinebarrel.com",
            "title": "How to buy a used barrel",
            "position": 1,
            "cited": true
          },
          {
            "sourceId": 902115,
            "url": "https://example.com/barrel-prices",
            "host": "example.com",
            "domain": "example.com",
            "title": "Barrel prices this year",
            "position": 0,
            "cited": false
          }
        ]
      }
    ],
    "nextAfter": "1793577600-1793663999-7-1793610000-83810"
  },
  "selector": "/v1/results/accounts/presence/answers",
  "duration": 0.05
}
```

## Example: Times an assistant showed no answer

```bash
curl "https://api.eu.silktide.com/v1/results/accounts/presence/answers?marketId=3&from=1793577600&to=1793663999&statuses=not_shown%2Cunavailable%2Cfailed" \
  -H "Authorization: silktide token=$SILKTIDE_API_KEY"
```

Response:

```json
{
  "result": {
    "workspaceId": 1,
    "from": 1793577600,
    "to": 1793663999,
    "limit": 100,
    "responses": [
      {
        "responseId": 83815,
        "promptId": 12,
        "promptText": "used oak barrels small wineries",
        "topicId": 7,
        "topicName": "Used barrels",
        "workspaceId": 1,
        "marketIds": [
          3
        ],
        "arena": "market",
        "region": {
          "regionId": 2,
          "name": "United States",
          "countryCode": "US",
          "stateCode": "",
          "language": "en-US"
        },
        "requestedAt": 1793610000,
        "platformId": "ai-overviews",
        "model": "",
        "status": "not_shown",
        "error": null,
        "truncated": false,
        "answer": null,
        "mentions": [],
        "sources": []
      }
    ],
    "nextAfter": null
  },
  "selector": "/v1/results/accounts/presence/answers",
  "duration": 0.03
}
```
