정보
이 스킬은 모든 Mailtrap API 요청 인증을 위한 확정 가이드를 제공하며, 토큰 선택, 안전한 저장, account_id 해결 방법을 다룹니다. API 호출을 구현하기 전에 이 스킬을 사용하여 권한 부여 헤더와 URL 매개변수를 올바르게 구성하세요. 이 스킬은 다른 Mailtrap 스킬들이 인증 패턴을 참조하는 중앙 기준 자료 역할을 합니다.
빠른 설치
Claude Code
추천npx skills add mailtrap/mailtrap-skills -a claude-code/plugin add https://github.com/mailtrap/mailtrap-skillsgit clone https://github.com/mailtrap/mailtrap-skills.git ~/.claude/skills/authorizing-api-requestsClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Authorizing Mailtrap API requests
Overview
Every Mailtrap API request needs two things:
- An API token in an auth header — proves identity and carries the scope.
- For account-scoped endpoints (most of them outside of the send hosts), an
account_idin the URL path.
This skill is the single source of truth for both. Other skills (sending-emails, testing-with-sandbox, using-email-templates, managing-contacts, setting-up-sending-domain) reference these conventions instead of duplicating them.
When to use
- Before writing any Mailtrap API call from code, scripts, CI, IaC, or an AI agent
- Picking which token scope and stream to provision
- Deciding where to store a token (env, secret manager, CI)
- Resolving the
account_idfor an account-scoped endpoint - Debugging
401 Unauthorized/403 Forbiddenresponses
API tokens
Create tokens at Settings > API Tokens with the smallest scope that works:
- Email Sending API — for
send.api.mailtrap.ioandbulk.api.mailtrap.io. Scope per stream (transactional, bulk) when possible. - Email Testing API — for the Sandbox (
sandbox.api.mailtrap.io). Always separate from live sending tokens. - Account-level API — for Contacts, Templates, Sending Domains, Suppressions, and other endpoints under
https://mailtrap.io/api/accounts/{account_id}/....
A single token can cover several scopes if the user has the right plan; prefer narrower tokens (one stream / one project / one product surface) so a leak has limited blast radius. Reference: API tokens documentation.
Auth headers (two equivalent forms)
Mailtrap accepts either header. Use Bearer in examples — it's the more common HTTP convention and matches most generated SDK code.
| Form | Header | When to use |
|---|---|---|
| Bearer (preferred) | Authorization: Bearer $MAILTRAP_API_TOKEN | Default for new code, SDKs, curl examples |
| Api-Token (legacy) | Api-Token: $MAILTRAP_API_TOKEN | Older clients or where Bearer is awkward |
Do not send both at the same time. The same value goes in either header.
Where to put tokens
- Local dev: environment variable, or
.envfile that is in.gitignore. Load withdirenv,dotenv, or the framework's built-in mechanism. - CI / build: the CI provider's encrypted secret store (GitHub Actions secrets, GitLab CI variables, CircleCI contexts). Inject as env vars only.
- Production / staging: a real secret manager (AWS Secrets Manager, GCP Secret Manager, Azure Key Vault, HashiCorp Vault, Doppler, 1Password, etc.). Rotate on a schedule.
- Agent / LLM workflows: the host agent's secret store. Never paste a token into chat or a prompt.
Hard rules:
- Never hardcode a token in source, config, or notebooks.
- Never commit a token. If one lands in git, rotate it; history retention is forever.
- Never pass a token on the command line as a flag — it leaks into shell history,
ps, and CI logs. - Never let an LLM echo a literal token back into generated code. Use
$VAR_NAMEshell-var placeholders in all examples so generated code reaches for the env var, not the literal. - Never mix sandbox and live tokens. A leaked sandbox key must not be able to send real mail.
Recommended env var names
These names are used consistently across every other skill in this repo and across the example snippets below.
| Variable | Used for |
|---|---|
MAILTRAP_API_TOKEN | General API: Email Send (transactional and bulk), Templates, Contacts, Sending Domains, Suppressions |
MAILTRAP_SANDBOX_API_TOKEN | Sandbox / Email Testing (separate scope) |
MAILTRAP_ACCOUNT_ID | Path parameter for account-scoped endpoints |
If your environment uses different names, alias them once at startup so the examples in other skills work unchanged.
Resolving account_id automatically
account_id is the integer prefix on every https://mailtrap.io/api/accounts/{account_id}/... endpoint. Do not hardcode it. It changes between environments, is different per organization, and is silently wrong when you copy a script to a teammate's account.
Resolve it once per session from the Accounts endpoint, which lists every account the token can access:
curl -s https://mailtrap.io/api/accounts \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN"
Response shape (array):
[
{"id": 12345, "name": "My Company", "access_levels": [1000]},
{"id": 67890, "name": "Client Account", "access_levels": [100]}
]
access_levels values:
1000— Account owner100— Admin10— Viewer (read-only on most endpoints)
One-liner to cache as an env var (pick the right account if the token can see more than one):
export MAILTRAP_ACCOUNT_ID=$(curl -s https://mailtrap.io/api/accounts \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" | jq '.[0].id')
Reference: Accounts API.
Quick reference
# Live sending (no account_id in path)
curl -X POST https://send.api.mailtrap.io/api/send \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{ ... }'
# Account-scoped endpoint
curl "https://mailtrap.io/api/accounts/$MAILTRAP_ACCOUNT_ID/contacts/lists" \
-H "Authorization: Bearer $MAILTRAP_API_TOKEN"
# Sandbox / Testing
curl -X POST "https://sandbox.api.mailtrap.io/api/send/$MAILTRAP_INBOX_ID" \
-H "Authorization: Bearer $MAILTRAP_SANDBOX_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{ ... }'
Common mistakes
| Mistake | Fix |
|---|---|
| Hardcoding the token in code, config, or a notebook | Load from $MAILTRAP_API_TOKEN (env, .env, CI secret, secret manager); rotate the token if it ever leaked |
Passing the token as a CLI flag (--token=...) | Use env vars; CLI flags leak to shell history, ps, and CI logs |
| Committing a token, then deleting it in a later commit | History keeps the value forever — rotate the token immediately, do not just remove the file |
| Pasting a token into chat / prompt / issue | Treat chat as public; rotate if it happened |
Using the live MAILTRAP_API_TOKEN against the sandbox host | Sandbox uses its own scope and MAILTRAP_SANDBOX_API_TOKEN; mixing them either fails or sends real mail by accident |
Hardcoding account_id | Resolve via GET https://mailtrap.io/api/accounts once per run and pass through $MAILTRAP_ACCOUNT_ID |
| Picking the wrong account when the token can see several | Filter the GET /api/accounts response by name or access_levels (1000 = owner) instead of .[0] |
Sending both Authorization and Api-Token headers | Pick one (Bearer for new code); duplicating them is unnecessary and confuses some intermediaries |
| Using a viewer-scoped token for writes | Check access_levels; writes need 100 (admin) or 1000 (owner) for the relevant account |
GitHub 저장소
자주 묻는 질문
authorizing-api-requests Skill이란 무엇인가요?
authorizing-api-requests은(는) mailtrap이(가) 만든 Claude Skill입니다. Skill은 Claude가 필요할 때 불러오는 지침과 리소스를 묶어 추가 프롬프트 없이 authorizing-api-requests 관련 작업을 수행할 수 있게 합니다.
authorizing-api-requests은(는) 어떻게 설치하나요?
이 페이지의 설치 명령을 사용하세요. authorizing-api-requests을(를) Claude Code 플러그인으로 추가하거나 저장소를 skills 디렉터리에 복제한 다음 Claude를 다시 시작해 Skill을 불러옵니다.
authorizing-api-requests은(는) 어떤 카테고리에 속하나요?
authorizing-api-requests은(는) 메타 카테고리에 속합니다.
authorizing-api-requests은(는) 무료로 사용할 수 있나요?
네. authorizing-api-requests은(는) AIMCP에 등록되어 있으며 무료로 설치할 수 있습니다.
연관 스킬
이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.
이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.
이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.
SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.
