Overview

The Keystone API enables test execution from any CI/CD platform or custom workflow. Perfect for non-GitHub users or advanced integrations.

Quick Start

# Trigger a test suite
curl -X POST https://api.keystone.ai/v1/suites/{suite_id}/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"environment": "staging"}'
Get your API key from Keystone Dashboard

Core Endpoints

Run Test Suite

POST /v1/suites/{suite_id}/run
curl -X POST https://api.keystone.ai/v1/suites/suite_123/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "environment": "staging",
    "base_url": "https://staging.example.com",
    "variables": {
      "USER_EMAIL": "test@example.com"
    }
  }'

Check Run Status

GET /v1/runs/{run_id}
const status = await fetch(`https://api.keystone.ai/v1/runs/${runId}`, {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}).then(r => r.json());

// Response
{
  "id": "run_456",
  "status": "completed",
  "passed": 45,
  "failed": 2,
  "duration": 234567,
  "artifacts_url": "https://..."
}

CI/CD Examples

GitLab CI

test:
  stage: test
  script:
    - |
      RUN_ID=$(curl -X POST https://api.keystone.ai/v1/suites/$SUITE_ID/run \
        -H "Authorization: Bearer $KEYSTONE_API_KEY" \
        -d '{"environment": "staging"}' \
        | jq -r '.run_id')
    
    - |
      while [ "$(curl -s https://api.keystone.ai/v1/runs/$RUN_ID \
        -H "Authorization: Bearer $KEYSTONE_API_KEY" \
        | jq -r '.status')" = "running" ]; do
        sleep 10
      done
    
    - |
      curl https://api.keystone.ai/v1/runs/$RUN_ID \
        -H "Authorization: Bearer $KEYSTONE_API_KEY" \
        | jq -e '.failed == 0'

Jenkins

pipeline {
  agent any
  
  stages {
    stage('E2E Tests') {
      steps {
        script {
          def response = httpRequest(
            url: "https://api.keystone.ai/v1/suites/${SUITE_ID}/run",
            httpMode: 'POST',
            customHeaders: [[name: 'Authorization', value: "Bearer ${KEYSTONE_API_KEY}"]],
            contentType: 'APPLICATION_JSON',
            requestBody: '{"environment": "staging"}'
          )
          
          def runId = readJSON(text: response.content).run_id
          
          // Poll for completion
          waitUntil {
            def status = httpRequest(
              url: "https://api.keystone.ai/v1/runs/${runId}",
              customHeaders: [[name: 'Authorization', value: "Bearer ${KEYSTONE_API_KEY}"]]
            )
            def result = readJSON(text: status.content)
            return result.status != 'running'
          }
        }
      }
    }
  }
}

CircleCI

version: 2.1

jobs:
  test:
    docker:
      - image: circleci/node:14
    steps:
      - run:
          name: Run Keystone Tests
          command: |
            # Trigger tests
            RUN_ID=$(curl -X POST https://api.keystone.ai/v1/suites/${SUITE_ID}/run \
              -H "Authorization: Bearer ${KEYSTONE_API_KEY}" \
              -d '{"environment": "staging"}' | jq -r '.run_id')
            
            # Wait for completion
            while [ "$(curl -s https://api.keystone.ai/v1/runs/$RUN_ID \
              -H "Authorization: Bearer ${KEYSTONE_API_KEY}" \
              | jq -r '.status')" = "running" ]; do
              sleep 10
            done
            
            # Check results
            FAILED=$(curl -s https://api.keystone.ai/v1/runs/$RUN_ID \
              -H "Authorization: Bearer ${KEYSTONE_API_KEY}" | jq -r '.failed')
            
            if [ "$FAILED" != "0" ]; then
              echo "Tests failed!"
              exit 1
            fi