Automate Sprint Environment Provisioning with Jira and Kinsta API
Create a Jira webhook for sprint_started events and a Node.js Express middleware that reads the board ID, maps it to a Kinsta site ID from .env, and calls the Kinsta API to create a new staging environment named after the sprint.
Set up the Jira webhook and Node.js middleware to automate staging environment creation for each sprint.
Summary
Agencies that run client WordPress projects on two‑week sprints often create a staging environment in MyKinsta manually before picking up a ticket. This manual step can be automated by hooking a Jira sprint_started webhook to a Node.js middleware that calls the Kinsta API. The middleware reads the board ID from the payload, looks up the corresponding Kinsta site UUID in a .env‑based map, and requests a new plain staging environment named after the sprint. The Kinsta API key and company ID are stored in .env, and the key must have developer‑level permissions to avoid permission errors.
To set up the integration, first generate a Kinsta API key via MyKinsta → Company Settings → API Keys and add it to .env alongside the company ID. Next, register a Jira webhook for sprint_started events either through the UI or the REST API, pointing to a /sprint endpoint on your middleware. The middleware, built with Express and dotenv, parses the raw body, verifies the HMAC signature, extracts sprint.originBoardId and sprint.name, resolves the site ID, and calls POST /sites/{siteId}/environments to create the environment. During local development you can expose the endpoint with ngrok, and the middleware logs the creation for audit purposes.
Key changes
- Generate Kinsta API key and store KINSTA_API_KEY and KINSTA_COMPANY_ID in .env
- Map Jira board IDs to Kinsta site UUIDs in .env
- Register a Jira sprint_started webhook pointing to /sprint endpoint
- Middleware parses raw JSON, verifies HMAC, extracts sprint.originBoardId and sprint.name
- Middleware resolves site ID and calls Kinsta API POST /sites/{siteId}/environments to create a plain staging environment
- Use Express.js and dotenv in Node.js project
- Expose local endpoint with ngrok for development and log creation events