canonical: https://jentic.com/apis/amazonaws.com/cloudtrail

# AWS CloudTrail

Jentic publishes the only available OpenAPI specification for AWS CloudTrail, keeping it validated and agent-ready. AWS CloudTrail records management and data events across an AWS account, delivers them to S3 or an event data store, and lets you query the log with CloudTrail Lake. The API covers trails, channels, event data stores, query execution, and resource policies, so an agent can configure logging, run SQL-like queries, and pull recent events without touching the console.

## For AI agents

Configure AWS CloudTrail trails, run CloudTrail Lake queries against event data stores, and look up recent management events across an AWS account. Backed by 44 endpoints covering trails, channels, queries, and event lookup.

## Scope

Does not handle real-time threat detection, log forwarding to non-AWS destinations, or in-account log retention beyond CloudTrail Lake - use for trail configuration, event lookup, and CloudTrail Lake queries only.

## Capabilities

- Create, describe, update, and delete CloudTrail trails for management and data events
- Create CloudTrail Lake event data stores and run SQL-style queries against captured events
- Look up the last 90 days of management events by attribute through LookupEvents
- Configure event selectors and insight selectors for fine-grained event capture
- Manage CloudTrail channels for ingesting events from external sources
- Attach and remove resource policies on CloudTrail resources for cross-account access
- Tag CloudTrail trails, event data stores, and channels for inventory and cost allocation

## Use cases

### Security Investigation with CloudTrail Lake

Security engineers use CloudTrail Lake to run SQL queries over months of event history without exporting logs to a separate SIEM. The API lets an agent create an event data store, start a query with StartQuery, poll DescribeQuery for completion, and pull rows with GetQueryResults. Common investigation queries include 'all ConsoleLogin events from a country' or 'every IAM policy change touching a role'.

Example prompt: Create a CloudTrail Lake query that returns all ConsoleLogin failures in the past 7 days, then fetch the results

### Compliance Logging Setup

Auditors expect every AWS account to have a multi-region CloudTrail trail covering management events. CreateTrail provisions the trail with an S3 bucket destination, PutEventSelectors enables data event capture for S3 and Lambda, and StartLogging activates delivery. DescribeTrails confirms configuration so agents can verify accounts against a baseline before a SOC 2 or ISO 27001 audit.

Example prompt: Create a multi-region trail named org-audit, attach S3 data event selectors for every bucket, and start logging

### Recent Event Lookup for Incident Response

When responding to an alert, an agent uses LookupEvents to retrieve the last 90 days of management events filtered by attribute (Username, EventName, ResourceName). This is faster than spinning up CloudTrail Lake when the question is 'what did this principal do recently?'. Results include the full event JSON for direct triage.

Example prompt: Look up the last 100 events where Username equals attacker-role over the past 24 hours and return the EventName values

### AI Agent Integration via Jentic

Through Jentic, an AI agent calls CloudTrail by searching for an intent like 'look up CloudTrail events for a user', loading the LookupEvents schema, and executing it with a LookupAttributes filter. Jentic signs the SigV4 request server-side using IAM credentials in your Jentic One instance.

Example prompt: Search Jentic for 'look up CloudTrail events for a user', load the LookupEvents schema, and execute it for Username=ci-deploy with MaxResults=50

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.CreateTrail | Create a CloudTrail trail |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.DescribeTrails | Describe one or more trails |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.CreateEventDataStore | Create a CloudTrail Lake event data store |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.GetQueryResults | Fetch results of a CloudTrail Lake query |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.DescribeQuery | Describe the status of a query |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.GetEventSelectors | Get current event selectors for a trail |
| POST | /#X-Amz-Target=com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.GetTrail | Get details of a specific trail |

## Key resources

- **Trail** — Create, describe, update, delete, start, and stop CloudTrail trails
- **Event Data Store** — Create CloudTrail Lake event data stores and configure their retention
- **Query** — Start, describe, cancel CloudTrail Lake queries and fetch their results
- **Channel** — Manage channels that ingest events from external sources into CloudTrail
- **Event Selectors** — Configure which management, data, and insight events a trail captures
- **Resource Policy** — Attach, get, and delete resource policies on CloudTrail resources

## Why Jentic

- **Setup:** Wiring AWS CloudTrail by hand means holding an access key ID and secret access key, computing an AWS Signature Version 4 signature per request, resolving the correct regional cloudtrail host with the right X-Amz-Target action header, and handling query polling, pagination, and retries yourself. Through Jentic you install once, import AWS CloudTrail from the API Directory, store the AWS access key once, and your agent calls it.
- **Permission scoping:** CloudTrail sends the trail name, event data store, and query identifiers in the request body rather than the URL path, so scope your agent by the operations it needs, such as looking up events or running a CloudTrail Lake query. You choose which operations it may call, so changes like creating or deleting a trail are not included unless you add them.
- **Credential handling:** Your AWS access key ID and secret access key are stored once, encrypted, by your own Jentic One instance, and the Signature Version 4 signature is computed at execution time. The raw keys never enter the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'look up CloudTrail events for a user' or 'run a CloudTrail Lake query', and Jentic returns the matching CloudTrail operation with its input schema so the agent calls the right action without crawling the AWS reference.

## Related APIs

- **Amazon GuardDuty** — GuardDuty consumes CloudTrail events as a primary data source for threat detection findings
- **AWS Security Hub** — Security Hub aggregates findings across AWS security services, including CloudTrail-based detections
- **AWS CloudHSM V2** — CloudHSM provides FIPS 140-2 Level 3 key custody whose access can be audited via CloudTrail

## FAQ

### Why is there no official OpenAPI spec for AWS CloudTrail?

AWS does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call AWS CloudTrail via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the AWS CloudTrail API use?

CloudTrail uses AWS Signature Version 4 (HMAC) signed requests with an IAM access key ID and secret. Through Jentic, those credentials live encrypted in your Jentic One instance and the SigV4 signature is computed server-side, so the agent context never holds the raw secret.

### Can I run CloudTrail Lake SQL queries with this API?

Yes. Call StartQuery with the SQL string and the EventDataStore ARN, poll DescribeQuery until the QueryStatus is FINISHED, then call GetQueryResults to page through rows. Queries support standard SELECT, WHERE, GROUP BY, and aggregate functions.

### What are the rate limits for the AWS CloudTrail API?

AWS applies per-account, per-region throttling on CloudTrail control-plane calls; LookupEvents is limited to a small number of TPS per account and returns ThrottlingException when exceeded. Use exponential backoff - the AWS SDKs Jentic wraps implement this automatically.

### How do I look up the last 90 days of events for a user with this API?

Call LookupEvents with a LookupAttributes entry of AttributeKey=Username and AttributeValue=<iam-user>. The response returns up to 50 events per page, including the full CloudTrailEvent JSON. Use NextToken to paginate.

### How do I run a CloudTrail query through Jentic with an AI agent?

Run pip install jentic, then have the agent search for 'run a CloudTrail Lake query', load the StartQuery schema, and execute it with the SQL string. Follow with DescribeQuery and GetQueryResults to retrieve rows once QueryStatus is FINISHED.

### Can I limit what my agent is allowed to do with the AWS CloudTrail API?

Yes. Jentic One is self-hosted, so you set the rules for which CloudTrail operations and AWS credentials your agent may use. Because CloudTrail passes the trail name, event data store, and query identifiers in the request body rather than the URL, you scope the agent by the operations it needs, such as LookupEvents for reading recent events or StartQuery and GetQueryResults for CloudTrail Lake queries. Higher-impact actions like CreateTrail or DeleteTrail stay off limits unless you explicitly grant them.
