CKAN API tokens: creation, expiry and revocation

A practical guide to issuing CKAN API tokens for publishing scripts and harvesters, adding expiry with the expire_api_token plugin, revoking tokens, and setting the correct header after the CKAN 2.11 rename.

On this page

When CKAN API tokens fit publishing scripts and harvesters

An API token is how an unattended publishing script or harvester authenticates to CKAN when no person is signing in. The token is a credential issued to a CKAN user account, and the job sends it with each API request, so the script never stores that user's password. Tokens suit scheduled jobs, bulk loaders and harvest runs that create or update datasets. Interactive editing in the web interface still uses a person's own login. Give each job its own token under a dedicated service account, so that revoking one token stops one job and leaves other jobs and staff untouched. Record which job uses which token in your run documentation, so that any revocation can be traced to a named job owner.

A token acts with the same permissions as the user who created it. If that account is a sysadmin or holds admin rights in an organization, the script inherits those rights, including the ability to delete datasets and change other members. The most important decision is therefore which account owns the token. Before issuing one, check the account's sysadmin status and its role in every organization the job writes to, and remove anything the job does not need. Permissions changed on the owner later also change what the token can do, so review the token and the owner's roles together during each periodic access check.

Expiry and revocation matter because a token that never expires keeps working after the job is retired, the owner leaves, or a copy of the token leaks into a log or repository. Revoke a token as soon as its job is decommissioned, and use the expire_api_token plugin where your portal needs tokens to expire on their own. Confirm that the plugin and the token behavior you rely on are supported on your CKAN version and alongside your other extensions, because the header name used to send the token changed after the CKAN 2.11 rename. Test creation, expiry and revocation on a staging portal running the same version. The CKAN release policy explains which minor versions still receive fixes.

Choosing CKAN API token settings for each publishing workflow

This table compares four decisions that shape a CKAN API token setup: the owning user, whether the token expires, whether scripts share a token, and who can revoke it. Read each row as one option, its trade-off and the workflow it suits. Confirm which options your CKAN version and installed plugins support before you write the token policy, because expiry and revocation behavior depends on the release and the extensions you run.

DecisionOptionTrade-offWhen it fits
Token ownerDedicated service accountSmaller blast radius and clearer audit trail, but roles must be designed up frontRecurring publishing scripts and harvesters that outlive any one staff member
Token ownerStaff member's own accountQuick to set up, but scripts depend on one person's account and rolesShort-term manual publishing by a single named editor
ExpiryNo expiryNo renewal work, but a leaked token stays usable until someone revokes itLow-risk internal jobs with a documented revocation owner
ExpiryExpiry set with expire_api_tokenLimits exposure and forces rotation, but each script needs a renewal step before the dateScheduled harvesters and publishing jobs with a regular credential review
SharingOne token per scriptRevoking one job leaves the others running, but more tokens to inventorySeveral jobs with different owners, schedules or data sets
SharingOne token shared by several scriptsFewer tokens to manage, but revoking it stops every job at onceA single small team job with one owner and one schedule
RevocationToken ownerFastest route for personal tokens, but fails if the owner is away or has leftPersonal tokens held by individual publishers
RevocationOrganization adminCovers team-owned tokens, but confirm in your version which tokens an admin can see and revokeDepartment publishing tokens tied to an organization
RevocationSysadminWorks as a last resort for incident response, but a large sysadmin group widens accessCompromised tokens when the owner and organization admin are unreachable

How CKAN checks a token on each API request

The diagram starts with a publishing script sending an API request that carries its token. CKAN resolves the token to the user who owns it, then checks expiry when the expire_api_token plugin is enabled. If the token passes, CKAN applies that user's organization and dataset roles to the requested action and returns the result or an authorization error. The final steps show revocation: once an admin revokes the token, later requests with it fail. When you read the flow, confirm which user each token resolves to, because that user's roles decide what the request can do.

Token checks on every request, including requests made after revocation.

How the expire_api_token plugin adds expiry to CKAN tokens

Long-lived tokens on unattended scripts are a risk because nobody reviews them after setup. A token pasted into a harvester configuration or a publishing cron job keeps working after its creator changes roles, after the script is retired, or after the config file is copied somewhere it should not be. The expire_api_token plugin is a CKAN extension that attaches an expiry date to each API token, so the token stops working on that date without anyone revoking it by hand. Before you plan around it, confirm that the plugin version you intend to use supports your installed CKAN version. CKAN minor releases can include backwards-incompatible changes, so an extension that works on one minor version may fail on the next. The CKAN release policy explains how the project moves between versions.

Set each token's lifetime from the schedule its script runs on. A harvester that runs weekly needs a lifetime that spans several runs, with time left to fix a failed run before the token lapses. Illustrative example: a monthly publishing job with a 35-day token would fail on day 36 if nobody rotated it, so the rotation should happen in a planned window ahead of each expiry date. Issue one token per script so that rotating one token does not interrupt the others. Record each token's expiry date and owner in your team's calendar or ticketing system. Agree on the rotation routine with the team that owns each job, because an expiry nobody tracks causes outages that look like data problems.

Confirm several behaviors in a test instance before any production script depends on the plugin. Check exactly how an expired token is reported to a client, including the HTTP status code and error body that a harvester or publishing script receives, so the job can raise an alert when it fails. Ask the plugin maintainers whether an existing token can be renewed or whether only a new token can be issued, and decide how a scheduled job will receive its replacement without a person copying it by hand. Finally, confirm in the plugin documentation which configuration file and key enable it, normally the plugins list in your CKAN configuration file, and verify the exact plugin name against the version you install before you restart the site.

Setting the token header name after the CKAN 2.11 rename

Portals on CKAN 2.10 and earlier expect the token header that scripts written before the rename were built around. If your publishing scripts, harvesters and scheduled jobs were written against these releases, they are the baseline for everything else on this page. Do not assume the same header works after an upgrade, because a call that succeeds on an older portal may be treated as unauthenticated on a newer one.

  • Inventory existing scripts: List every publishing script, harvester and scheduled job that sends a token, and record which portal version each one targets.
  • Keep old scripts pinned: Leave scripts that target an older portal unchanged until that portal is upgraded, then change them in the same window as the upgrade.
  • Check support status: The CKAN release policy describes support for the latest patch of the current minor version and the previous minor version, so confirm whether your 2.10 patch still receives fixes before you plan around it.
  • Run a read call first: Use a read call that returns something only an authenticated user can see, and confirm the token is accepted before you test any write.
  • Watch for silent fallback: A failed authentication may return public-only results instead of an error, so compare each result with what the token holder should be able to see.

Before you change a publishing script on these releases, confirm the header name in the API documentation for your exact installed version and verify it with a read call.

Setting up CKAN API tokens for a publishing script

This sequence takes a publishing script from an unclear credential to a token with a known owner, a limited organization role, a set expiry and a tested revocation path. Each step closes with a check you can record, so the setup can be reviewed before the script writes to any live dataset. Work through the steps in order, because later checks depend on earlier ones.

  1. Confirm the CKAN version and patch

    Check which minor version your portal runs and whether it is on the latest patch of that minor. CKAN supports the latest patch of the current minor and the previous minor, and older patches lose support once a newer one ships. The releases published on August 26, 2026 were 2.12.0 and the maintenance releases 2.11.6 and 2.10.11. Record the version and patch level in the change ticket, because the header name and plugin behavior depend on them. Done when the record matches the version shown on your portal.

  2. Create a dedicated service account

    Create a separate account for the script with no personal login attached and no sysadmin flag. Give it the lowest organization role the job needs, such as member or editor, depending on whether the script must create or only update datasets, and confirm the role in the organization's member list. Then sign in as that account and try one action it should be able to perform and one it should not, such as editing a dataset in another organization. Done when the account belongs only to the intended organization and both checks behave as expected.

  3. Enable expiry with the plugin

    If your policy requires tokens to expire, enable the expire_api_token plugin by adding it to the plugins setting in your CKAN configuration, then restart the services that serve the portal. Check the plugins list on the running instance to confirm it loads, and read the startup log for errors. If your policy allows tokens that never expire, skip the plugin and record that exception with the approver's name. Done when the plugin appears in the active list on staging and the expiry decision is written down.

  4. Issue the token and store it securely

    Create the token under the service account and copy it into the team's secrets manager at once, under a name that identifies the script and its owner. Set the expiry date chosen in the previous step where the plugin asks for one. Do not paste the value into tickets, chat, source control or shared documents, and limit read access in the vault to the identity the script runs under. Done when the secret exists in the vault and a search of your ticketing, chat and repository tools finds no copy of the token value.

  5. Verify the header with read and staging write

    Confirm the header name your CKAN version expects, since CKAN 2.11 renamed the token header, and send one read call with the token against a dataset the account can see. Then make a test write to a staging dataset in the target organization and check the change in the web interface and the API response. Running the write on staging means a wrong header or missing permission cannot affect live records. Done when the read and the write both return the expected results and the header name is recorded in the runbook.

  6. Confirm expired and revoked tokens fail

    Test the rejection path before the script goes live. On staging, send a call with a token that has passed its expiry date, if expiry is enabled, and a call with a token you revoke for the test. Both calls should be refused. Check whether the refusals appear in the audit logs your team relies on, and keep the requests and responses as evidence for the next upgrade. Done when both cases are refused and the revocation steps are tested and written in the runbook.

  7. Record owner, expiry and revocation contact

    Add a runbook entry with the token owner, the service account name, the organization it can write to, the expiry date, the secrets manager location and the revocation contact. Set a renewal reminder in your team's ticketing or calendar tool ahead of the expiry date. Ask someone outside the owning team to review the entry, and ask the revocation contact to confirm they can revoke the token on request. Done when the review is signed off and the reminder exists.

Security risks of CKAN API tokens in scripts and harvesters

Each API token in a publishing script or harvester is a standing credential that acts as a user in CKAN. The five risks below share one root cause: a token is copied, widened or forgotten faster than anyone reviews it. Work through them in order and confirm the matching control for each.

Tokens in repositories and CI logs

A token pasted into a harvester config, a notebook or a CI job definition is readable by anyone with repository access, and a token echoed in build output can persist in log retention. Confirm that tokens live only in a dedicated secrets store and are injected into jobs at run time. Also check that the CI system masks secret values and that forks and pull requests cannot read them. Scan history as well as the current branch, because deleting a file does not remove the token from earlier commits.

Broad rights inherited from staff accounts

A token created from a personal sysadmin or broad-editor account carries every right that account holds, including rights the script never needs. When the person changes roles or leaves, the script's access changes with them or stops working unexpectedly. Confirm that each token belongs to a least-privilege service account whose organization memberships match only the datasets the job publishes. Review which site-wide rights that account holds, and keep sysadmin rights off automation accounts.

One token shared across scripts

When several harvesters and publishing scripts share one token, revoking it stops all of them, and nobody can tell which job made a given change. A leaked copy also points to no single job. Confirm that every script or harvester has its own token with a name that identifies its job and owner. Then check that you can revoke one token without touching the others, and test that revocation on a non-production portal first.

Tokens in proxy and application logs

Reverse proxies and application servers can log request headers for debugging, and a header carrying the API token is then written to disk, shipped to a log platform and kept for as long as retention allows. The same applies to debug output from a harvester that prints its request. Confirm that log redaction removes the token header at every layer, including the proxy, the application and any log shipper. Then test by sending a request with a dummy token and searching the logs for it.

No owner or review date

A long-lived token with no named owner and no review date outlives the project that created it. Nobody is asked whether the harvester still runs, so the credential keeps working after its purpose has ended. Confirm that every token has a named owner, a recorded purpose and a review date that matches your policy. Use expiry on the token where your CKAN setup supports it, such as the expire_api_token plugin covered in this topic, and make a documented review the step that renews or revokes each token.

Revoking CKAN API tokens when people, scripts or secrets change

Revoke a CKAN API token as soon as the person, script or secret behind it stops being trusted. Four triggers justify it: a token owner leaves the organization or changes role, a publishing script is retired, a token appears in a log file or a code repository, or a harvester moves to new infrastructure. Work in a fixed order. First, revoke the old token so it can no longer be used. Then issue the replacement to the new owner, script or host, and store it in your secrets manager, keeping it out of configuration files. Finally, confirm the old token fails by sending one request with it, which should be refused. Record the date, the trigger and the person who ran each step so the change can be traced later.

Before your runbook relies on a revocation step, confirm who can perform it in your installed CKAN version. Check whether a token owner can revoke their own tokens from their user profile, whether organization admins can see or revoke tokens held by members of their organization, and whether sysadmins can revoke any token on the site. Confirm also whether revocation is available in the web interface, the API or both, and write down the path your team will use. Keep the number of people who can do this small, but make sure at least one other person can act when an owner is unavailable, such as after a sudden departure. Test each path on a staging site first, using a disposable token.

Revoking a token stops future access but does not undo changes already made with it. Datasets created, edited, deleted or made public through the token stay in that state until someone changes them. After revoking, review the activity recorded for the account and for the datasets, organizations and harvest sources the token touched, starting from the date you believe the exposure began. Confirm what your deployment records: whether activity streams or audit logs capture API writes, which user each change is attributed to, and how long those records are kept. Where logging is missing for that period, treat the affected datasets as unverified and check them against the source. Restore any unwanted changes and note them in your change record.

Limits to confirm in your CKAN version and extensions

Five items decide whether CKAN API tokens behave as your team expects in your installed version. Each one needs a check on a test site with the extensions you actually run, because the answers depend on the version and the plugins enabled. Confirm them before any publishing script or harvester depends on tokens.

Exact token header name

Confirm the exact request header that carries the token in the CKAN version you run. The name was changed after CKAN 2.11, so examples copied from older guides, or from a different minor release, may send a header your instance does not read. Send one authenticated write and one read of a private dataset from a test script, then record which header succeeded and which failed. Store the confirmed name in your publishing scripts and harvester configuration so later upgrade checks have a fixed reference.

expire_api_token compatibility

The expire_api_token plugin is what adds expiry to tokens, so check that a version of it supports the CKAN release you run and is still actively maintained. Ask the maintainer or the plugin's repository which CKAN versions it has been tested against and whether it still receives fixes. Then test that a token past its expiry is refused, and that a token created before the plugin was enabled is handled as you expect. Record the answers before you write expiry into your token policy.

Audit log visibility

Find out whether creating, using and revoking tokens leaves a record your compliance team can read. Web server access logs may show requests without naming the token owner, and CKAN application logs may not record token events in every version, so test each source directly. Confirm where each event is written, how long it is kept, and who can read it: sysadmins, organization admins, or only the operators of the server. Settle this before an assessor asks for evidence of token revocation.

SSO and authorization extensions

Check how API tokens behave when sign-in is handled by an identity provider rather than CKAN's own login. If you use ckanext-saml2auth for single sign-on, confirm what happens to existing tokens when a user is removed from the identity provider or their role changes through SAML2 attributes. Custom authorization overrides can also change what a token is allowed to do. Test a token for a user whose access was reduced, and confirm that revocation works after the change.

saml2auth repository

Behavior across minor upgrades

Patch releases do not break backwards compatibility, but minor releases may include backwards-incompatible changes, so a minor upgrade can change how tokens are created, sent or checked. Read the release notes for your target minor version before scheduling the upgrade, and confirm that your expire_api_token version supports it. Repeat the header, expiry and revocation tests on a staging copy with your extensions enabled, and keep the results with the upgrade record.

Release policy

CKAN API token questions buyers ask before hiring help

What drives the cost of hiring help with CKAN API tokens?

Cost follows the number of scripts, harvesters and publishing organizations that need tokens, plus how much extension work sits around them. Each script or harvester has its own owner, role and expiry rules, so more of them means more design, configuration and testing. Custom extensions that touch authentication or the API add review time, especially if they must be checked against more than one CKAN version. The number of publishing organizations matters because each one usually needs its own role mapping and sign-off. Effort is paid for by the partner's time on scoping, implementation, testing and handover, and it is largely one-time. Recurring costs come from retesting after upgrades and from token rotation procedures your team keeps running. When you request a quote, ask for the cost split by these items so you can see which parts you could take on yourself.

Can our own team handle CKAN API token setup and revocation in-house?

Yes, a single script with a clear runbook can usually be handled by your own platform team. Creating a token, setting its expiry and revoking it are routine CKAN administration tasks once the procedure is written down and tested on a staging instance. A partner is most useful in two places: designing the role model so each token has the least access the script needs, and testing the setup across the CKAN versions you run or plan to run. Those tasks take experience with how organization roles and the expire_api_token plugin interact, and mistakes there are easy to miss. A practical split is for your team to own day-to-day token issuance and revocation while a partner designs the model and verifies it. Confirm that your team has sysadmin access in a staging environment before deciding.

What do we need to provide before a CKAN token project starts?

Your team needs to provide admin access to a staging instance, an inventory of scripts and harvesters with their owners, and a named approver who signs off on roles. The staging instance should mirror production closely enough to test token behavior, including organization memberships and the plugins that handle authentication. The inventory is usually where projects start: for each script, record which account or token it uses, which organizations it publishes to, what it reads and writes, and who to call when it fails. The named approver decides which roles each script receives and accepts the revocation and expiry rules. Without that approver, role decisions stall during testing. Ask whether your security or identity team also needs to review the design, since that can add a step before cutover.

How long does a CKAN API token project take to complete?

Timing depends on the written scope, so ask for a fixed-scope plan that lists dates for each deliverable. Timing turns on the number of scripts and harvesters, the extensions involved, the number of CKAN versions to test and how quickly your approver and staging access are available. Most engagements are fixed-scope, which means scope, deliverables and timelines are agreed in writing before work starts. Ask the partner to show which tasks depend on your team's responses, such as access requests and sign-offs, because those waits are a common cause of slipped dates. Also ask how the plan handles a finding during cross-version testing that changes the role design. A good plan separates the build period from the cutover window and states when each token will be revoked and reissued. Ask for the plan in writing before comparing timelines across quotes.

Will a CKAN upgrade break our existing API tokens and scripts?

A CKAN upgrade can break token use, so confirm the token header and the expire_api_token plugin on the target version before cutover. Patch releases are designed not to break backwards compatibility, while minor releases may include incompatible changes, so the upgrade path matters. Check the release notes for the header name your target version expects, since the token header was renamed in CKAN 2.11 and scripts still sending the old name can fail. Confirm that the plugin loads and enforces expiry on that version, and that existing tokens still authenticate. Test every script against staging with actual token values, including harvesters that run on schedules. Keep the old token until each script passes, then revoke it. The CKAN release policy describes which versions get fixes and how patch and minor releases differ.

What should a quote for CKAN API token work include?

A quote should list the scope in writing: which scripts, harvesters and organizations are covered, and which extensions and plugins are included. It should name the environments, such as staging and production, and say who prepares and who applies changes in each one. Deliverables should be spelled out: the token inventory, the role model, the expiry and revocation procedure, the runbook for your team, and the test results. Retest should be defined too, including which CKAN versions are covered and what happens if a finding requires a change. Ask what your team must provide and what is excluded, such as upgrades or ongoing support. Ongoing support, upgrades and continuous testing are available as retainers, so ask separately for any recurring work. A quote with these parts lets you compare offers on the same basis.

How DeployOpen scopes and delivers CKAN token management

DeployOpen treats CKAN API tokens as credentials that need a named owner, a defined lifetime and a tested removal path. We scope which publishing scripts and harvesters need tokens, configure expiry with the expire_api_token plugin and revocation in your own CKAN instance, then test and document the result. Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory every publishing script, harvester and integration that will call the CKAN API with a token.
  • Agree in writing who owns each token, which organization it publishes to, and its permitted actions.
  • Set expiry periods and a rotation owner for each token class before any build work starts.

How we build

  • Confirm the CKAN version and token header name in your environment, since the header was renamed in CKAN 2.11.
  • Install and configure the expire_api_token plugin in your CKAN configuration, then verify expiry on test tokens.
  • Build revocation steps for lost credentials, departed staff and retired scripts, and test each one.

How we hand over

  • Document token creation, expiry settings, the revocation procedure and the header name for each script owner.
  • Provide a retest record showing that expired and revoked tokens are refused by the CKAN API.
  • Walk through the runbook with your administrators so token rotation does not rely on one person.

How we support

  • Offer ongoing support as a retainer for token audits, rotation reviews and CKAN upgrades.
  • Re-check token settings after each CKAN upgrade, since header names and plugin behavior can change between versions.
  • Confirm response and support terms in the written scope before signing.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.