Skip to main content

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
ParameterLocationTypeDescription
idpathintegerScript 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
ParameterLocationTypeRequiredDescription
qquerystringNoFilter 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
ParameterLocationTypeRequiredDescription
idqueryintegerNoFilter 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
}
FieldRequiredDescription
server_idNoServer 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
}
FieldRequiredDescription
script_idsNoScript IDs to run. If omitted, runs all jobs in the schedule.
server_idNoServer 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.

With rules (Jobs)

  1. Obtain token in Configuration → API access
  2. 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 in schedules the jobs it participates in (id, name)
  3. GET /api/v1/schedules?id=... to verify scripts and rules for the chosen schedule
  4. POST /api/v1/schedules/:id/run (optional: script_ids, server_id)
  5. GET /api/v1/runs/:id until status indicates completion

Without rules (Scripts)

  1. Obtain token in Configuration → API access
  2. GET /api/v1/scripts?q=... to obtain the script id
  3. POST /api/v1/scripts/:id/executions (optional: server_id)
  4. GET /api/v1/executions/:id until status indicates completion