# Publish text source units

Publish a deterministic representation from owned retained plain text or CSV bytes.

Documentation index: https://webcite.co/llms.txt
Canonical page: https://webcite.co/api-docs/publish-text-representation
API origin: https://api.webcite.co
Authentication: x-api-key header. Keep keys on your server.

## When to use it

Use the sourceVersionId from [Register retained source bytes](/api-docs/register-source) or a versioned upload. Inspect the returned units before choosing a zero-based figure_index for [numeric verification](/api-docs/numeric).

## Request

POST /api/v2/sources/{versionId}/representations/text

No model call or fixed public credit price is specified.

### curl

```curl
curl --fail-with-body -X POST 'https://api.webcite.co/api/v2/sources/YOUR_VERSIONID/representations/text' \
  -H "x-api-key: $WEBCITE_API_KEY"
```

### Node.js

```javascript
const response = await fetch("https://api.webcite.co/api/v2/sources/YOUR_VERSIONID/representations/text", {
  method: "POST",
  headers: {
    "x-api-key": process.env.WEBCITE_API_KEY,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.json());
```

### python

```python
import os
import requests

response = requests.post(
    "https://api.webcite.co/api/v2/sources/YOUR_VERSIONID/representations/text",
    headers={"x-api-key": os.environ["WEBCITE_API_KEY"]},
    timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
```

## Response

Returns sourceVersionId, representationId, parserVersion, and sourceUnitId with locator and state for each unit.

## Errors

Rejects a foreign source, unsupported media type, invalid UTF-8, empty content, or source over 1 MiB.

## OpenAPI operation

```json
{
  "path": "/api/v2/sources/{versionId}/representations/text",
  "method": "POST",
  "operation": {
    "operationId": "SourceVersionController_publishTextRepresentation",
    "parameters": [
      {
        "in": "path",
        "name": "versionId",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    ],
    "responses": {
      "201": {
        "description": ""
      }
    },
    "security": [
      {
        "x-api-key": []
      },
      {
        "bearer": []
      }
    ],
    "tags": [
      "Versioned evidence"
    ]
  },
  "schemas": {}
}
```
