{
  "info": {
    "name": "OpenCronAPI",
    "description": "OpenCronAPI REST API — distributed HTTP cron scheduling service. Full collection covering Jobs, Executions, Account, and Internal endpoints.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "opencronapi-collection-v1"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.opencronapi.com",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "",
      "type": "string",
      "description": "Your OpenCronAPI API key — find it in Console → Settings"
    }
  ],
  "auth": {
    "type": "apikey",
    "apikey": [
      {
        "key": "key",
        "value": "X-API-Key",
        "type": "string"
      },
      {
        "key": "value",
        "value": "{{api_key}}",
        "type": "string"
      },
      {
        "key": "in",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Jobs",
      "description": "Create and manage cron jobs",
      "item": [
        {
          "name": "List Jobs",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs?page=1&per_page=20",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs"],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "per_page", "value": "20" }
              ]
            },
            "description": "Returns a paginated list of all your cron jobs."
          },
          "response": []
        },
        {
          "name": "Create Job (Interval)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Health check\",\n  \"url\": \"https://myapp.com/health\",\n  \"method\": \"GET\",\n  \"schedule_type\": \"interval\",\n  \"interval_seconds\": 300,\n  \"timeout_seconds\": 30,\n  \"retry_count\": 3,\n  \"retry_delay_seconds\": 60,\n  \"expected_status_code\": 200,\n  \"notify_on_failure\": true,\n  \"notify_on_success\": false\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/v1/jobs",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs"]
            },
            "description": "Create a new interval-based cron job."
          },
          "response": []
        },
        {
          "name": "Create Job (Cron Expression)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Daily DB backup trigger\",\n  \"url\": \"https://myapp.com/webhooks/backup\",\n  \"method\": \"POST\",\n  \"headers\": {\n    \"Authorization\": \"Bearer secret123\",\n    \"Content-Type\": \"application/json\"\n  },\n  \"body\": \"{\\\"type\\\": \\\"full\\\"}\",\n  \"body_type\": \"json\",\n  \"schedule_type\": \"cron\",\n  \"cron_expression\": \"0 3 * * *\",\n  \"timezone\": \"Europe/Prague\",\n  \"timeout_seconds\": 60,\n  \"retry_count\": 3,\n  \"notify_on_failure\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/v1/jobs",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs"]
            },
            "description": "Create a job with a cron expression schedule (requires Starter plan or above)."
          },
          "response": []
        },
        {
          "name": "Create Job (Once)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Send newsletter\",\n  \"url\": \"https://myapp.com/webhooks/newsletter\",\n  \"method\": \"POST\",\n  \"body_type\": \"json\",\n  \"body\": \"{\\\"campaign\\\": \\\"march-2026\\\"}\",\n  \"schedule_type\": \"once\",\n  \"run_at\": \"2026-04-01T09:00:00Z\",\n  \"notify_on_failure\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/v1/jobs",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs"]
            },
            "description": "Schedule a one-time job."
          },
          "response": []
        },
        {
          "name": "Get Job",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Get details of a specific job."
          },
          "response": []
        },
        {
          "name": "Update Job",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Content-Type", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Health check (updated)\",\n  \"url\": \"https://myapp.com/health\",\n  \"method\": \"GET\",\n  \"schedule_type\": \"interval\",\n  \"interval_seconds\": 600,\n  \"timeout_seconds\": 30,\n  \"retry_count\": 5,\n  \"notify_on_failure\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Update an existing job."
          },
          "response": []
        },
        {
          "name": "Delete Job",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Permanently delete a job and all its execution history."
          },
          "response": []
        },
        {
          "name": "Pause Job",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id/pause",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id", "pause"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Pause a job — it will not execute until resumed."
          },
          "response": []
        },
        {
          "name": "Resume Job",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id/resume",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id", "resume"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Resume a paused job."
          },
          "response": []
        },
        {
          "name": "Trigger Job",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id/trigger",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id", "trigger"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Manually trigger a job execution outside of its regular schedule."
          },
          "response": []
        },
        {
          "name": "Get Job Executions",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id/executions?page=1&status=failure&from=2026-03-01&to=2026-03-31",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id", "executions"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "status", "value": "failure", "description": "Filter by status: success, failure, timeout, retry, skipped" },
                { "key": "from", "value": "2026-03-01", "description": "ISO date filter start" },
                { "key": "to", "value": "2026-03-31", "description": "ISO date filter end" }
              ]
            },
            "description": "Get paginated execution history for a specific job."
          },
          "response": []
        },
        {
          "name": "Get Job Stats",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/jobs/:id/stats",
              "host": ["{{base_url}}"],
              "path": ["v1", "jobs", ":id", "stats"],
              "variable": [{ "key": "id", "value": "1", "description": "Job ID" }]
            },
            "description": "Get aggregated statistics for a job (success rate, avg response time, etc.)."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Executions",
      "description": "View execution history and details",
      "item": [
        {
          "name": "List All Executions",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/executions?page=1&status=failure",
              "host": ["{{base_url}}"],
              "path": ["v1", "executions"],
              "query": [
                { "key": "page", "value": "1" },
                { "key": "status", "value": "failure", "description": "Filter: success, failure, timeout, retry, skipped" }
              ]
            },
            "description": "Get global execution history across all your jobs."
          },
          "response": []
        },
        {
          "name": "Get Execution",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/executions/:id",
              "host": ["{{base_url}}"],
              "path": ["v1", "executions", ":id"],
              "variable": [{ "key": "id", "value": "1", "description": "Execution ID" }]
            },
            "description": "Get full details of a specific execution including response headers and body preview."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Account",
      "description": "Account info, plan, and usage",
      "item": [
        {
          "name": "Get Account Info",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/account",
              "host": ["{{base_url}}"],
              "path": ["v1", "account"]
            },
            "description": "Get account information including current plan and usage."
          },
          "response": []
        },
        {
          "name": "Get Usage Stats",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/v1/account/usage",
              "host": ["{{base_url}}"],
              "path": ["v1", "account", "usage"]
            },
            "description": "Get usage statistics for the current billing period."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Internal (Node Agents)",
      "description": "Internal API used by node agents — requires node token, not API key",
      "item": [
        {
          "name": "Heartbeat",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Node-Token", "value": "{{node_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"node_id\": 1,\n  \"current_load\": 12,\n  \"ram_mb\": 512,\n  \"cpu_percent\": 34\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/internal/heartbeat",
              "host": ["{{base_url}}"],
              "path": ["internal", "heartbeat"]
            },
            "description": "Node sends heartbeat every 30 seconds."
          },
          "response": []
        },
        {
          "name": "Get Pending Jobs",
          "request": {
            "method": "GET",
            "header": [
              { "key": "X-Node-Token", "value": "{{node_token}}" }
            ],
            "url": {
              "raw": "{{base_url}}/internal/pending-jobs",
              "host": ["{{base_url}}"],
              "path": ["internal", "pending-jobs"]
            },
            "description": "Fetch jobs due for execution."
          },
          "response": []
        },
        {
          "name": "Post Execution Result",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-Node-Token", "value": "{{node_token}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"job_id\": 1,\n  \"status\": \"success\",\n  \"http_status_code\": 200,\n  \"response_time_ms\": 142,\n  \"response_body_preview\": \"{\\\"ok\\\":true}\",\n  \"response_size_bytes\": 10,\n  \"scheduled_at\": \"2026-03-28T10:00:00Z\",\n  \"started_at\": \"2026-03-28T10:00:00Z\",\n  \"completed_at\": \"2026-03-28T10:00:00Z\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{base_url}}/internal/execution-result",
              "host": ["{{base_url}}"],
              "path": ["internal", "execution-result"]
            },
            "description": "Node posts the execution result after completing an HTTP call."
          },
          "response": []
        }
      ]
    }
  ]
}
