# Report an outcome

Source: https://immiscible.fly.dev/docs/api/post-v1-outcomes

`POST /v1/outcomes`

Close the loop on a task so spend becomes yield. Only the person who owns the task, or an admin key, may report it.

| Field | Description |
|---|---|
| `taskId` | the task (from `x-immiscible-task-id` or the `immiscible` field) |
| `status` | `accepted`, `rejected`, `abandoned` or `partial` |
| `value` | optional: the outcome's value in the workload's unit |
| `acceptedCallIds` | optional: which attempts were used, for an exact yield |

## Authentication

Workspace key. A gateway key (`ask_...`) issued under Keys in the console, sent as `Authorization: Bearer` or `x-api-key`. It binds traffic to a person or service, a team and optionally a task class.

## Request

curl:

```bash
curl -X POST "https://immiscible.fly.dev/v1/outcomes" \
  -H "authorization: Bearer $IMMISCIBLE_KEY" \
  -H "content-type: application/json" \
  -d '{
    "taskId": "tsk_b5f8c335e4a6",
    "status": "accepted",
    "acceptedCallIds": [
      "cal_19f2"
    ]
  }'
```

Node:

```ts
const res = await fetch('https://immiscible.fly.dev/v1/outcomes', {
  method: 'POST',
  headers: {
    authorization: `Bearer ${process.env.IMMISCIBLE_KEY}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    taskId: 'tsk_b5f8c335e4a6',
    status: 'accepted',
    acceptedCallIds: ['cal_19f2'],
  }),
});
const data = await res.json();
console.log(res.status, data);
```

Python:

```python
import os
import requests

res = requests.post(
    "https://immiscible.fly.dev/v1/outcomes",
    headers={
        "authorization": f"Bearer {os.environ['IMMISCIBLE_KEY']}",
        "content-type": "application/json",
    },
    json={
        "taskId": "tsk_b5f8c335e4a6",
        "status": "accepted",
        "acceptedCallIds": ["cal_19f2"],
    },
)
print(res.status_code, res.json())
```
