API reference

JIT Guard public machine API

v0.1.03 operationsOpenAPI 3.1.0

Scoped contract for the routes jitguard-core owns directly.

Machine-readable contract for the public HTTP API routes that jitguard-core owns. This is a deliberately scoped first pass: it covers only the routes declared in this repository's own Terraform route maps. Routes declared by other repositories (jitguard-engine, jitguard-aws, jitguard-billing, jitguard-integrations) are not described here yet. Adding one requires updating the drift-check allowlist (IN_SCOPE_PATHS in scripts/check-openapi-drift.mjs) in the same change. There is no /v1 prefix. The paths here are the paths deployed today. Error responses on the audit routes use RFC 7807 application/problem+json with a stable type, requestId, and the legacy error member for one release. Every response from those handlers carries X-Request-Id, derived from the API Gateway request id; a client-supplied header is not trusted.

Base URL

  • https://{apiHost} — Deployment-specific API host. Use the environment's app host.

Authentication

customerAuth

http · bearer · JWT

CUSTOM (API Gateway REQUEST) customer authorizer, deployed by jitguard-auth as auth-customer-authorizer and attached to these routes as authorization_type = "CUSTOM". Send the Cognito app-pool access token (not the ID token) as Authorization: Bearer <token>. The authorizer validates the token, resolves the member's customerId and role from the membership table, and passes them to the handler as authorizer context. It is not cached, so membership changes apply on the next request. A missing, invalid or non-member token is rejected before the handler runs.

Audit

Customer-visible audit trail reads.

GET/customer/audit

List the caller organisation's audit trail for one day

Returns one page (up to 50 items) of audit records for the caller's organisation on the requested UTC calendar day. The customer is always taken from the CUSTOM authorizer context; a customerId query parameter is neither accepted nor honoured. The response is the existing { items, nextCursor } envelope. Pass the returned nextCursor back as cursor to fetch the next page; a null cursor means the day is exhausted.

Operation ID
listCustomerAudit
Authentication
customerAuth

Parameters

NameInTypeDescription
datequerystring (date)UTC calendar day to read, YYYY-MM-DD. Defaults to the current UTC day when omitted. The handler does not validate the format; an unparseable value simply matches no audit rows.
cursorquerystringOpaque pagination cursor: the SK of the last item from the previous page (the nextCursor value). Omit it for the first page.

Responses

200One page of audit records for the requested day.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/jsonAuditPage
401The request carried no usable customer identity. A CUSTOM authorizer rejection happens before the handler runs, so API Gateway may supply its own 401 body in that case; when the handler itself sees no customer id it returns this problem body.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/unauthenticated",
  "title": "Unauthorized",
  "status": 401,
  "detail": "A valid customer access token is required.",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "Unauthenticated"
}
405The handler only serves GET.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/method-not-allowed",
  "title": "Method Not Allowed",
  "status": 405,
  "detail": "Method not allowed",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "Method not allowed"
}
500The Lambda is misconfigured (for example, missing table binding), or an unexpected error escaped the handler. Unexpected errors are logged with the request id but their internal message is never returned.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/internal-error",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "The audit table is not configured for this deployment.",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "DYNAMODB_TABLE not configured"
}
GET/customer/audit/export

Export the caller organisation's audit trail for a date range

Returns every audit record for the caller's organisation in the inclusive from..to window as a downloadable file. The window is capped at 31 days. Every day is paged to exhaustion, so a successful export is never silently truncated. format=csv returns text/csv; format=json returns a top-level JSON array of audit items (not the { items, nextCursor } page envelope). Both responses carry a Content-Disposition attachment header. The customer is always taken from the CUSTOM authorizer context; a customerId query parameter is neither accepted nor honoured.

Operation ID
exportCustomerAudit
Authentication
customerAuth

Parameters

NameInTypeDescription
fromrequiredquerystring (date)First UTC calendar day in the export window, inclusive.
torequiredquerystring (date)Last UTC calendar day in the export window, inclusive. Must be on or after from, and the inclusive window must not exceed 31 days.
formatrequiredquery"csv" | "json"Export file format.

Responses

200The requested audit export.
  • Content-Disposition — string, required — Attachment filename, jitguard-audit-<from>_to_<to>.<format>.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
text/csvstring
"createdAt","action","reason","region","resource","result","actorType","actorId","requestId","promotionId","details"
"2026-07-10T10:00:00Z","account_mutated","sync:org_sync","us-east-1","111111111111","success","service","org-sync","req-1","","{""region"":""us-east-1""}"
application/jsonarray of AuditItem
400Invalid export query. The response is an RFC 7807 application/problem+json body. The legacy error member carries the exact message pre-RFC clients already read; detail repeats it for problem-aware clients.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/validation-error",
  "title": "Bad Request",
  "status": 400,
  "detail": "from must be a valid date in YYYY-MM-DD format",
  "instance": "/customer/audit/export",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "from must be a valid date in YYYY-MM-DD format"
}
401The request carried no usable customer identity. A CUSTOM authorizer rejection happens before the handler runs, so API Gateway may supply its own 401 body in that case; when the handler itself sees no customer id it returns this problem body.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/unauthenticated",
  "title": "Unauthorized",
  "status": 401,
  "detail": "A valid customer access token is required.",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "Unauthenticated"
}
405The handler only serves GET.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/method-not-allowed",
  "title": "Method Not Allowed",
  "status": 405,
  "detail": "Method not allowed",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "Method not allowed"
}
500The Lambda is misconfigured (for example, missing table binding), or an unexpected error escaped the handler. Unexpected errors are logged with the request id but their internal message is never returned.
  • X-Request-Id — string, required — Stable id for this request, also present as requestId in problem bodies. It is the API Gateway request id, so it matches the id in the Lambda logs; quote it in support requests.
application/problem+jsonProblem
{
  "type": "https://api.jitguard.com/problems/internal-error",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "The audit table is not configured for this deployment.",
  "instance": "/customer/audit",
  "requestId": "7c1d0c2e-4bd4-4e2f-9c42-4f4b9c0f2b1a",
  "error": "DYNAMODB_TABLE not configured"
}

Health

Unauthenticated liveness probe.

GET/health

Unauthenticated liveness probe

Returns a constant {"status":"ok"} once API Gateway can route to the health Lambda. It has no dependencies, so it proves routing only; it is not a readiness or dependency probe.

Operation ID
getHealth
Authentication
None (public)

Responses

200The API can route to the health Lambda.
application/jsonobject { status }

Schemas

AuditItem

object { action, reason, region, resource, result, actorType, actorId, createdAt, requestId, promotionId, details }

The customer-visible audit item shape. GET /customer/audit wraps these in AuditPage; a JSON export is a bare array of them. CSV columns are the same fields in this order: createdAt, action, reason, region, resource, result, actorType, actorId, requestId, promotionId, details.

FieldTypeDescription
actionrequiredstringWhat happened, e.g. account_mutated.
reasonrequiredstringWhy it happened, e.g. sync:org_sync. Empty when unknown.
regionrequiredstringAWS region from the audit record's details. Empty when absent.
resourcerequiredstringThe affected resource identifier (often an AWS account id).
resultrequired"success" | "failure" | "noop" | "partial"
actorTyperequired"user" | "service"
actorIdrequiredstringStable identifier of the actor.
createdAtrequiredstring (date-time)Record timestamp, derived from the audit row's sort key.
requestIdrequiredstringRequest/correlation id for the audited operation.
promotionIdrequiredstringPromotion id when the action came from a promotion; otherwise empty.
detailsrequiredmap of stringFree-form audit details supplied by the writing domain.

AuditPage

object { items, nextCursor }
FieldTypeDescription
itemsrequiredarray of AuditItem
nextCursorrequiredstring | nullCursor for the next page, or null when the day is exhausted.

Problem

object { type, title, status, detail, instance, requestId, error, message, field }

RFC 7807 problem details, served as application/problem+json. The legacy error member is kept for one release so pre-RFC clients keep working. message and field appear only where the pre-migration response carried them. Extension members are allowed by RFC 7807 and may be added without a breaking change.

FieldTypeDescription
typerequiredstring (uri-reference)Stable problem-type URI, e.g. https://api.jitguard.com/problems/validation-error. Clients should switch on this, not on title or detail.
titlerequiredstringShort, human-readable summary of the problem type.
statusrequiredintegerHTTP status code, duplicated here for problem-aware clients.
detailrequiredstringExplanation specific to this occurrence.
instancerequiredstring (uri-reference)Request path that produced the problem, e.g. /customer/audit.
requestIdrequiredstringSame value as the X-Request-Id response header.
errorrequiredstringLegacy error member, identical to the pre-migration response. Present for one release; new clients should use type/detail.
messagestringLegacy additional message, present only when the old response had one.
fieldstringLegacy validation field name, present only when the old response had one.

Source & refresh

This page and /openapi.yaml are built from the same checked-in snapshot, which is copied fromJITGuard/jitguard-core's openapi.yaml. The snapshot is pinned by commit and SHA-256 in scripts/openapi-source.json; CI fails if either changes without a refresh. See docs/openapi.md in the public site repo for the refresh and drift-check steps.