While we're here, let's remove APIError:

```python
return jsonify(error="Field agent_id missing"), BAD_REQUEST
```

Feel free to add more to the error if you think it would be more descriptive of the problem.