Vault

Vault Token Types Done Right: A Practical Guide to service vs batch

2026-04-19
NicheeLab Editorial Team

Vault attaches access policies to tokens. The distinction between service and batch tokens shows up constantly in day-to-day operations and is also a frequent Associate exam topic.

This article organizes the lifecycle, constraints, representative use cases, and selection criteria from a practitioner's perspective. Minor behavior may shift between versions, but the fundamentals covered here are stable.

The Big Picture of Token Types

Vault tokens come in two broad flavors: service and batch. A service token is a persistent token with server-side state that you can renew, revoke, and look up. A batch token is a lightweight token that is not stored server-side; its expiry and permissions are fixed at issuance, and it cannot be renewed or individually revoked.

Their verification flows differ. Service tokens consult the token store on every request, while batch tokens are verified by signature and the metadata embedded in the token itself. Batch is the default pick for high-throughput, short-lived workloads; service is the default for long-running services.

  • Every auth method lets you set token_type to service or batch via a role or config (most defaults are service when left unspecified)
  • Service tokens are stored in the token store and support lookup / renew / revoke
  • Batch tokens are non-stored, non-renewable, and non-revocable (they expire only when their TTL elapses). Policies are frozen at issuance

Service vs batch verification flow

Client RequestVault (API Server)Service TokenBatch TokenLookup store / Load policies / Check TTL+renewable / EnforceVerify HMAC / Read embedded policies+exp / Check TTL (no renew) / Enforce

Start by issuing a default (service) token and inspecting it

vault token create -policy=default -ttl=1h
# 出力されたトークンを lookup(service は可能)
vault token lookup s.XYZ...

Service Token Characteristics and Operations

Because service tokens are kept in the token store, you can look them up, renew them, revoke them immediately, perform partial revocation by accessor, or cascade-revoke a token tree. Use them for long-running applications, daemons, and Vault Agent auto-renewal scenarios.

They support management features like periodic tokens (usable indefinitely as long as they keep being renewed) and orphan tokens (unaffected by parent revocation). The cubbyhole, a per-token transient KV store, is also a service-token-only feature.

  • renewable: can be renewed within TTL (up to max_ttl)
  • revoke: immediate revocation by ID, accessor, or prefix
  • periodic: when -period is set, the token stays valid as long as it is renewed
  • orphan: can be issued without a parent in the token hierarchy
  • cubbyhole: per-token transient KV available

Typical operations (renew, revoke, periodic, orphan)

# service トークン発行(1時間)
vault token create -policy=app -ttl=1h

# 更新(さらに30分延長、max_ttl に依存)
vault token renew s.ABC... 30m

# 即時失効(ID で)
vault token revoke s.ABC...
# アクセサーで失効
evault token revoke -accessor hvs.abc...

# periodic トークン(24時間周期で更新必須)
vault token create -policy=agent -period=24h

# orphan トークン
evault token create -policy=ops -orphan

Batch Token Characteristics and When to Use Them

Batch tokens are lightweight tokens that are not recorded in server storage. Verification relies on a signature and embedded metadata. They cannot be renewed, individually revoked, or looked up. They fit short-lived, high-throughput workloads such as CI/CD, serverless, batch processing, and map-reduce jobs.

A key distinction: the TTL and policies determined at issuance are frozen for the token's lifetime. Subsequent changes to roles, identity groups, or policies do not modify the permissions of previously issued batch tokens.

  • renew / revoke / lookup: none are supported (the token expires only by TTL)
  • Use-count limits like num_uses are not supported
  • No cubbyhole support (there is no server-side state for the token)
  • Policy is frozen at issuance (later policy changes are not reflected)
  • Designed for highly concurrent, short-lived workloads (issuance and verification are cheap)

Issuing a batch token and confirming the constraints

# batch トークンを 15 分で発行
vault token create -type=batch -policy=build -ttl=15m

# lookup は失敗(batch は参照不可)
vault token lookup s.BATCH...   # => エラー: batch token は lookup 不可

# revoke も不可(期限到来を待つ)
vault token revoke s.BATCH...   # => エラー: batch token は revoke 不可

Selection Criteria and Representative Use Cases

Pick based on whether you need lifecycle management and whether policy changes must propagate. If you need long-running tokens, immediate permission changes, or forced revocation, choose service. If you want per-job, short-lived, high-volume issuance with minimal overhead, choose batch.

For exam preparation, lock in the fact that batch tokens cannot be renewed, revoked, or looked up, and that their policy is fixed.

  • Long-running workloads, rolling renewals, or forced revocation needed → service
  • Short jobs, high-volume issuance, throughput-sensitive paths → batch
  • Need policy changes to take effect immediately → choose service
ItemService TokenBatch TokenExam Takeaway
Server-side stateYes (token store)None (not stored)Batch is never persisted
RenewSupported (bound by max_ttl/period)Not supportedBatch is always non-renewable
RevokeImmediate (by ID, accessor, or prefix)Not supported (TTL only)You cannot individually revoke a batch token
lookupSupportedNot supportedBatch cannot be looked up
cubbyholeSupportedNot supportedBatch has no cubbyhole
Policy propagationEvaluated per request (later changes propagate)Frozen at issuancePermission changes after issuance do not apply to batch tokens

Example: using token_type with AppRole

# AppRole で batch を発行する role を作成
vault write auth/approle/role/ci \
  token_policies=build \
  token_ttl=15m \
  token_max_ttl=30m \
  token_type=batch

# 長期運転サービス向けの service 役割
evault write auth/approle/role/app \
  token_policies=app \
  token_ttl=1h \
  token_max_ttl=24h \
  token_type=service

Operations and Security Considerations

Renewal and revocation are the operational pillars for service tokens. Use Vault Agent auto-renewal, design max_ttl thoughtfully, and standardize accessor-based partial revocation. Tree and prefix revocation are powerful for mass invalidation during incidents.

Batch tokens lean on short TTLs to time-box leak exposure. Because you cannot revoke them individually, contain leaks by disabling the role or issuance path and temporarily isolating the affected system. Also consider your Vault token verification key rotation policy (any operational change must be validated carefully ahead of time).

  • Service: design TTLs, automate renewal with Agent, manage accessors, and document immediate revocation procedures
  • Batch: short TTLs, least privilege, audited issuance paths, and a containment plan for leaks
  • For both types, detect anomalies via audit logs and metrics

Minimal example: auto-renew a service token with Vault Agent

# agent.hcl の一例
auto_auth {
  method "approle" {
    mount_path = "auth/approle"
    config = {
      role_id_file_path   = "/etc/vault/role_id"
      secret_id_file_path = "/etc/vault/secret_id"
    }
  }
  sink "file" {
    config = { path = "/var/run/vault/token" }
  }
}
cache {
  use_auto_auth_token = true
}
listener "tcp" { address = "127.0.0.1:8200" tls_disable = true }

Associate Exam Pitfalls Checklist

When you see keywords like renew, revoke, lookup, or cubbyhole, instantly recognize that batch does not support them. Another frequent topic is whether policy changes after issuance propagate (service tends to propagate; batch is frozen).

Watch for use-case translation questions, too. Long-running services and Agent flows belong to service tokens; CI/CD and serverless workloads belong to batch tokens.

  • Batch: non-renewable, non-revocable, no lookup, frozen policy
  • Service: renewable, immediate revocation, lookup-capable, supports cubbyhole
  • When asked about use cases, decide based on whether lifecycle management is required

Minimal commands to validate your understanding

# batch かどうかの違いを体で覚える
vault token create -type=batch -policy=dev -ttl=10m
vault token lookup <batch_token>   # 失敗するはず
vault token create -policy=dev -ttl=10m
vault token lookup <service_token> # 成功するはず

Check Your Understanding

Associate

問題 1

A short-lived CI job reads secrets from Vault. The permissions at issuance time are sufficient, and individual renewal or immediate revocation is not required. Which token type should you choose, and which statement about that token is correct?

  1. A. Batch token. It is not stored server-side, cannot be renewed or individually revoked, and its policy is frozen at issuance until the TTL expires.
  2. B. Batch token. By specifying periodic, it can be renewed indefinitely.
  3. C. Service token. Because it has no accessor, it cannot be revoked, but lookup is supported.
  4. D. Service token. It cannot use cubbyhole, but issuance is lighter than batch.

正解: A

Batch is the right fit for short-lived workloads like CI. Batch tokens are non-stored, non-renewable, and non-revocable; the permissions captured at issuance are frozen until the TTL expires. B is wrong (batch tokens have no periodic option). C is wrong (service tokens have accessors and can be revoked). D is wrong (cubbyhole is available on service tokens, and batch is the lighter issuance path).

Frequently Asked Questions

Can I use dynamic secrets with a batch token?

Reading dynamic secrets itself works. Secret leases are managed by the secret engine, so retrieval and expiration still function even when the caller uses a batch token. However, because the token itself cannot be revoked immediately, you must mitigate leak risk with short TTLs, least-privilege policies, and the ability to cut off issuance paths.

Can I apply policy changes to an existing batch token after issuance?

No. A batch token freezes its policy at issuance time. To apply a policy change, issue a new token and switch the job to use it. If you need to swap permissions or revoke immediately, choose a service token from the start.

How do I respond to a leak of a batch token I cannot revoke individually?

Reduce risk operationally. Use short TTLs, least privilege, encrypted and audited distribution paths, per-job issuance, and the ability to quickly disable the role or block the execution platform when anomalies surface. Wider-impact actions like rotating Vault's verification key should be planned carefully and validated in a staging environment first.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Vault

Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)

Vault fundamentals — sealed/unsealed state, auth methods, se...

Vault

Vault Operations Professional (VOP-003): Complete Guide (2026)

Pass the Vault Operations Professional exam — enterprise pat...

Vault

Vault Path-Based Routing: API URL Structure (2026)

How Vault's path-based routing works — mount points, sub-pat...

Vault

Vault Tokens: Auth Token Mechanics (2026)

Token fundamentals — service vs. batch tokens, accessor, ren...

Vault

Vault Token Types: Service, Batch, Periodic (2026)

Service vs. batch tokens compared — performance, ACL behavio...

Browse all Vault articles (101)
© 2026 NicheeLab All rights reserved.