Direct Answer

You can manage RedirHub redirects as code today by keeping them in a file in your repository and applying it from CI with the RedirHub API. A RedirHub Terraform provider is coming soon; early access is available on request and can be set up for your workspace in as little as 3 days.

Why manage redirects as code#

  • Every change is reviewed in a pull request and has a history in git.
  • Redirects ship with the site change that needs them, from the same pipeline.
  • The same file can recreate a workspace's redirects, for example for a staging domain.

Today: a redirects file and the API#

  1. Keep redirects.csv in your repository with the columns source_url, destination and type, the same format as the CSV import.
  2. Store an API token as a CI secret (REDIRHUB_TOKEN). Each token is scoped to one workspace.
  3. On merge, run a script that creates the rows that don't exist yet with POST /links and updates the ones whose destination changed with PUT /links/{id}. The script in Create, update and delete redirects in bulk with the API is a starting point.
yaml# .github/workflows/redirects.yml
name: Apply redirects
on:
  push:
    branches: [main]
    paths: [redirects.csv]
jobs:
  apply:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install requests
      - run: python scripts/apply_redirects.py redirects.csv
        env:
          REDIRHUB_TOKEN: ${{ secrets.REDIRHUB_TOKEN }}

To see what a change would do before it runs, preview bulk updates with POST /bulk/summary, which returns the matched links and the first before-and-after destinations without writing anything.

Terraform provider (coming soon)#

A RedirHub provider for Terraform and OpenTofu is coming soon, so domains and redirects can be declared as resources next to your DNS and CDN, with plan and apply like the rest of your stack. Early access is available now on request and can be ready for your workspace in as little as 3 days.

To request early access, use the contact form or email success@redirhub.com with your workspace name, the tool you use (Terraform or OpenTofu) and roughly how many domains and redirects you manage.

Want redirects in Terraform? The RedirHub Terraform provider is coming soon. Get early access in as little as 3 days.

Request early access

Frequently asked questions

It is coming soon. Early access is available on request through the contact form or success@redirhub.com, and it can be set up for your workspace in as little as 3 days. Until then, the API covers the same jobs from any CI pipeline.

Yes. Keep them in a CSV or JSON file in your repository and apply it on merge with the RedirHub API.

The API is plain JSON over HTTPS with a Bearer token, so any tool that can make HTTP requests can use it. Ask us if you need a native provider for your tool.

Related help

View All Articles