Skip to content

MT-23076: add --expires-at to tokens create and reset - #12

Draft
oshchyhol wants to merge 4 commits into
mainfrom
MT-23076-cli-api-token-expiration
Draft

MT-23076: add --expires-at to tokens create and reset#12
oshchyhol wants to merge 4 commits into
mainfrom
MT-23076-cli-api-token-expiration

Conversation

@oshchyhol

@oshchyhol oshchyhol commented Aug 7, 2026

Copy link
Copy Markdown

Motivation

MT-23076

The API token endpoints now accept an expires_at attribute. The CLI needs a way to set a token expiry on create and reset, including the explicit "never expires" case.

Changes

  • tokens create gains an --expires-at flag mapped to the expires_at param of the createApiToken operation (POST /api/api_tokens)
  • tokens reset gains the same flag mapped to the now-optional request body of the resetApiToken operation (POST /api/api_tokens/{id}/reset); without the flag the command still posts no body, exactly as before
  • tri-state semantics: flag omitted – key absent from the request body (server default applies, a 1-year default is being rolled out behind a feature flag); --expires-at never (case-insensitive sentinel) – explicit "expires_at": null, token never expires; any other value – passed through verbatim as a string
  • no client-side date validation – past, unparseable, or more-than-5-years-ahead values are rejected by the server with a 422, which the CLI surfaces through its standard error path
  • docs: README command table and examples, skills/mailtrap-cli/references/accounts.md flag tables

How to test

  • mailtrap tokens create --name t1 --permissions '[...]' (no --expires-at) – request body has no expires_at key; the created token gets the server default expiry
  • mailtrap tokens create --name t2 --permissions '[...]' --expires-at 2027-06-01T00:00:00Z – token is created with that expiry, EXPIRES_AT column shows it
  • mailtrap tokens create --name t3 --permissions '[...]' --expires-at never (also try NEVER) – token is created without an expiry
  • mailtrap tokens create --name t4 --permissions '[...]' --expires-at 2020-01-01T00:00:00Z – command exits non-zero and prints the server 422 error to stderr
  • mailtrap tokens reset --id <id> (no --expires-at) – behaves exactly as before this change: empty request body, new token value printed
  • mailtrap tokens reset --id <id> --expires-at 2027-06-01T00:00:00Z and --expires-at never – new token gets that expiry / no expiry
  • mailtrap tokens list / tokens get --id <id> – unchanged, EXPIRES_AT column still renders

Companion PRs

Caveat: release/merge only after falcon deploys MT-23076 and zap_api_token_expiration is enabled in production.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bac42ab-9f5a-4710-88d7-4103b8f5c8b8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant