API (external)
Gredit exposes a REST API under the /api/v1/ namespace for programmatic integration from external tools (CI/CD, scripts, custom services). All endpoints in this section share the same JWT authentication scheme.
For routes used by the web application, see Internal API. For federated SAML authentication, see SAML endpoints.
Authentication
Requests to /api/v1/* require a JWT token in the Authorization header:
Authorization: Bearer <token>
The token is obtained in Configuration → API access. Its validity depends on the Account configuration (token interval and frequency). A single token authorizes access to all endpoints documented on this page (issues, executions, etc.).
Issues
Issues by script
Returns issues generated by a specific script.
GET /api/v1/scripts/:id/issues
| Parameter | Location | Type | Description |
|---|---|---|---|
id | path | integer | Script ID |
Example:
curl -H "Authorization: Bearer $TOKEN" \
https://gredit.example.com/api/v1/scripts/42/issues
Issues by status
Returns a summary of issues grouped by status.
GET /api/v1/scripts/issues_by_status
Example:
curl -H "Authorization: Bearer $TOKEN" \
https://gredit.example.com/api/v1/scripts/issues_by_status
Executions
The execution API lets you enqueue runs and script executions. Operations are asynchronous: the initial response returns an ID to poll for status and output. Executions originated through this API are recorded with source: api.
Discovery
List scripts
GET /api/v1/scripts
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
q | query | string | No | Filter by name (substring, case-insensitive). E.g. ?q=ANCAP |
Response: array of scripts with id, name, language, database, and schedules (array with id and name of each job the script participates in).
List schedules
GET /api/v1/schedules
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
id | query | integer | No | Filter a specific schedule. E.g. ?id=7 |
Response: array of schedules with id, name, scripts (each job with job_id, script_id, script_name, server_id), and rules (array with id and name).
Run script (no rules)
Runs a script in isolation. Does not trigger rules; the result is queried as an execution.
POST /api/v1/scripts/:id/executions
Body (optional):
{
"server_id": 6
}
| Field | Required | Description |
|---|---|---|
server_id | No | Server to run on. If omitted, uses the account default server. |
Response (201):
{
"execution_id": 55,
"script_id": 42,
"script_name": "Cierre diario",
"status": "pending"
}
Run schedule (with rules)
Runs jobs from a schedule. When the script finishes, rules configured for that job are triggered.
POST /api/v1/schedules/:id/run
Body (optional):
{
"script_ids": [42, 87],
"server_id": 3
}
| Field | Required | Description |
|---|---|---|
script_ids | No | Script IDs to run. If omitted, runs all jobs in the schedule. |
server_id | No | Server to run on. If omitted, uses the job's server. |
Response (201):
{
"runs": [
{ "run_id": 101, "script_id": 42, "script_name": "Cierre diario", "status": "pending" },
{ "run_id": 102, "script_id": 87, "script_name": "Envío reportes", "status": "pending" }
]
}
Polling
Get run (with rules)
GET /api/v1/runs/:id
Response: id, status, source, started_at, ended_at, stdout, stderr, script_id, schedule_id.
Get execution (no rules)
GET /api/v1/executions/:id
Response: id, status, source, started_at, ended_at, stdout, stderr, script_id.
Recommended flow
With rules (Jobs)
- Obtain token in Configuration → API access
- Identify the schedule:
- If you know the job:
GET /api/v1/schedules?id=... - If you only know the script:
GET /api/v1/scripts?q=...— each script includes inschedulesthe jobs it participates in (id,name)
- If you know the job:
GET /api/v1/schedules?id=...to verify scripts and rules for the chosen schedulePOST /api/v1/schedules/:id/run(optional:script_ids,server_id)GET /api/v1/runs/:iduntilstatusindicates completion
Without rules (Scripts)
- Obtain token in Configuration → API access
GET /api/v1/scripts?q=...to obtain the scriptidPOST /api/v1/scripts/:id/executions(optional:server_id)GET /api/v1/executions/:iduntilstatusindicates completion