> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theslow.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest Metric

> Submit a new metric payload for a specific project in your SlowNet account using an API key.

## Endpoint

```
POST https://theslow.net/api/slowstats/ingest-metrics
```

## Overview

This endpoint allows you to submit arbitrary metric data for a project.\
Use it to track analytics, counters, or any structured data you want tied to your project.

## Authentication

This endpoint requires an API key. You can retrieve an API key from your [dashboard](https://theslow.net/dashboard). Include it in the `X-API-KEY` header:

```
X-API-KEY: YOUR_API_KEY_HERE
```

For more details, see the [Authentication Guide](https://docs.theslow.net/authentication).

## Request Body

Send a JSON payload with the following structure:

| Field       | Type   | Required | Description                                         |
| ----------- | ------ | -------- | --------------------------------------------------- |
| `projectId` | string | Yes      | ID of the project to associate the metric with.     |
| `payload`   | object | Yes      | Arbitrary JSON object representing the metric data. |

## Responses

### ✅ 200 OK

Metric successfully ingested:

```json theme={null}
{
  "message": "Metric ingested successfully."
}
```

### ⚠️ 400 Bad Request

If `projectId` or `payload` is missing or invalid:

```json theme={null}
{
  "error": "Project ID is required."
}
```

Or

```json theme={null}
{
  "error": "Metric payload is required and must be an object."
}
```

### 🔒 401 Unauthorized

If authentication fails (invalid or missing API key):

```json theme={null}
{
  "error": "Unauthorized: You must provide a valid API Key."
}
```

### 🚫 403 Forbidden

If the project does not belong to the authenticated user:

```json theme={null}
{
  "error": "Forbidden: You do not have access to this project."
}
```

### 💥 500 Internal Server Error

For unexpected server errors:

```json theme={null}
{
  "error": "An internal server error occurred."
}
```

## Examples

### CURL

```bash theme={null}
curl -X POST "https://theslow.net/api/slowstats/ingest-metrics"      -H "Content-Type: application/json"      -H "X-API-KEY: YOUR_API_KEY_HERE"      -d '{
       "projectId": "abc123",
       "payload": {
         "temperature": 72.5,
         "humidity": 45
       }
     }'
```

### Python (requests)

```python theme={null}
import requests

headers = {"X-API-KEY": "YOUR_API_KEY_HERE"}
data = {
  "projectId": "abc123",
  "payload": {
    "temperature": 72.5,
    "humidity": 45
  }
}

response = requests.post("https://theslow.net/api/slowstats/ingest-metrics", json=data, headers=headers)
print(response.json())
```

### JavaScript (fetch)

```javascript theme={null}
fetch("https://theslow.net/api/slowstats/ingest-metrics", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-KEY": "YOUR_API_KEY_HERE"
  },
  body: JSON.stringify({
    projectId: "abc123",
    payload: {
      temperature: 72.5,
      humidity: 45
    }
  })
})
  .then(res => res.json())
  .then(data => console.log(data));
```

## Notes

* This endpoint enforces **ownership checks**, meaning you can only submit metrics for projects tied to your API key.

## Need Further Assistance?

If you have any questions or encounter issues, please don't hesitate to reach out to our [support team](https://theslow.net/dashboard#support).
