Journal the upstream calls a run's sidecar dispatched

Sidecar-only. Auth via Bearer run token. A batch of the upstream calls the run's sidecar dispatched for its integrations (the api_call tool, the MITM listener, a remote MCP server's operations, a local MCP server's tools/call when no MITM listener sees its upstream requests), one record per call that may have reached the upstream, taken from its final attempt. Each is written to the connection-call journal (connection_calls) with the run's organization, space, actor and API key, auth_method run_token, run_id set and a null request_id (the batch's request is not the call's); the sidecar sends none of those. A record carries its call_id and called_at, stored as the row's call_id and called_at: (run_id, call_id) is unique, so a batch sent twice is stored once and the second answers 204 as well. Every record is checked before any is written, against the run's frozen kickoff snapshot alone — never the live agent or the space's activation, so a call that left stays journaled when its integration is switched off or the agent edited or deleted mid-run: a non-null connection_id is one the run bound to that integration (else 400 connection_not_in_run), and a record with a null connection_id names an integration the run resolved (else 400 invalid_request); one record that fails refuses the whole batch. The text of a record is bounded at 2048 characters and stored truncated to the journal's own caps. A run with no actor writes nothing and answers 204. A record carrying credential_revision (a 2xx answered with that credential) also ends the connection's rejection streak: a non-OAuth2 connection's count of consecutive upstream rejections is reset to 0, unless the connection no longer holds that credential, the run's actor can no longer reach it (deleted, unshared, moved to another space), or it is already flagged needsReconnection. An OAuth2 connection's count tracks token refreshes and is left untouched. A token whose run is no longer running is refused (403).

POST/internal/integration-calls

Authorization

bearerExecToken
AuthorizationBearer <token>

Run token for container-to-host internal routes.

In: header

Request Body

application/json

curl -X POST "https://your-instance/internal/integration-calls" \  -H "Content-Type: application/json" \  -d '{    "calls": [      {        "call_id": "0d0a16ab-a508-4d58-bf24-5dc3cb248f3e",        "called_at": "2019-08-24T14:15:22Z",        "integration_id": "string",        "connection_id": "d3547de1-d1f2-4344-b4c2-17169b7526f9",        "method": "string",        "host": "string",        "outcome": "string",        "duration_ms": 0      }    ]  }'
Empty
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string",
  "code": "string",
  "request_id": "string",
  "param": "string",
  "retry_after": 0,
  "login_refusal": "grant",
  "integration_diagnostic": "string",
  "errors": [
    {
      "field": "string",
      "code": "string",
      "message": "string",
      "title": "string",
      "line": 1,
      "column": 1,
      "candidate_connections": [
        {
          "id": "string",
          "label": "string",
          "account_id": "string",
          "owned_by_actor": true,
          "needs_reconnection": true,
          "scopes_granted": [
            "string"
          ],
          "missing_scopes": [
            "string"
          ]
        }
      ],
      "connection_id": "string",
      "missing_scopes": [
        "string"
      ],
      "remedy": "new_connection",
      "owned_by_actor": true,
      "required_scopes": [
        "string"
      ],
      "auth_key": "string",
      "required_auth_key": "string",
      "available_auth_keys": [
        "string"
      ],
      "source": "admin_pin",
      "connect_url": "http://example.com",
      "expiresAt": "2019-08-24T14:15:22Z",
      "packageId": "string"
    }
  ]
}
{
  "type": "https://docs.appstrate.dev/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Invalid or missing session",
  "code": "unauthorized",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "Insufficient permissions",
  "code": "forbidden",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "Resource not found",
  "code": "not_found",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/rate-limited",
  "title": "Rate Limited",
  "status": 429,
  "detail": "Too many requests. Please try again shortly.",
  "code": "rate_limited",
  "request_id": "req_abc123",
  "retry_after": 30
}
{
  "type": "https://docs.appstrate.dev/errors/internal-error",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "An unexpected error occurred. Please try again or contact support.",
  "code": "internal_error",
  "request_id": "req_abc123"
}