Skip to content

API Reference ​

GrydJobs exposes three REST API controllers for managing jobs, recurring schedules, and the dead letter queue.

All endpoints return RFC 7807 ProblemDetails on errors and require a session plus a permission:

RouteOrganization (tenant permission, granted to Admin)Platform (platform permission)
GET /jobs, GET /jobs/{id}, executions, dashboard/stats, GET /recurring-jobs, GET /recurring-jobs/{id}read:jobs — the jobs of its own tenantread:jobs — also the jobs that belong to no tenant
POST /jobs/{id}/cancelmanage:jobs — a job of its own tenantmanage:jobs
POST /jobs (dispatch by type name), every write of /recurring-jobs—manage:jobs
/dead-letter-jobs—read:jobs (list), manage:jobs (retry, purge)

Platform Operator holds both platform permissions; Platform Support holds read:jobs. Dispatching a job by NAME is the platform's alone: the route cannot tell which job is safe in an organization's hands. A product that lets its users start a job exposes a route of its own, under its own permission, and schedules the job in process through IJobScheduler — jobs scheduled that way run in their tenant with no user and need none of these permissions.

jobTypeName must name a concrete class implementing IJob<TArgs> (IRecurringJob for recurring schedules): anything else is refused with 400 before any type is constructed.

Jobs ​

Base path: GET /api/v1/jobs

List Jobs ​

http
GET /api/v1/jobs?page=1&pageSize=20&status=Processing&queue=default&orderBy=CreatedAt&ascending=false

Query Parameters:

ParameterTypeDefaultDescription
pageint1Page number
pageSizeint20Page size
statusenum—Filter by status (Enqueued, Processing, Succeeded, Failed, etc.)
typeenum—Filter by type (FireAndForget, Delayed, Recurring, Continuation)
priorityenum—Filter by priority (Low, Normal, High, Critical)
queuestring—Filter by queue name
searchTermstring—Search in job type name
orderBystringCreatedAtSort field
ascendingboolfalseSort direction

Response: 200 OK — PagedResult<JobSummaryDto>

Get Job by ID ​

http
GET /api/v1/jobs/{id}

Response: 200 OK — JobSummaryDto | 404 Not Found

Get Execution History ​

http
GET /api/v1/jobs/{id}/executions?page=1&pageSize=20

Response: 200 OK — PagedResult<JobExecutionDto> | 404 Not Found

Get Dashboard Stats ​

http
GET /api/v1/jobs/dashboard/stats

Response: 200 OK — JobDashboardStatsDto

json
{
  "totalJobs": 1523,
  "enqueuedJobs": 12,
  "processingJobs": 4,
  "succeededJobs": 1480,
  "failedJobs": 15,
  "deadLetteredJobs": 3,
  "scheduledJobs": 8,
  "recurringJobs": 5,
  "averageExecutionDurationMs": 342.5,
  "totalExecutions": 4210
}

Enqueue Job ​

http
POST /api/v1/jobs
Content-Type: application/json

{
  "jobTypeName": "MyApp.Jobs.SendEmailJob, MyApp",
  "serializedArgs": "{\"to\":\"user@example.com\"}",
  "argsTypeName": "MyApp.Jobs.SendEmailArgs, MyApp",
  "priority": "Normal",
  "queue": "default",
  "scheduledAt": null,
  "maxRetries": 3
}

Response: 201 Created — JobSummaryDto | 400 Bad Request

Cancel Job ​

http
POST /api/v1/jobs/{id}/cancel

Response: 200 OK | 404 Not Found | 400 Bad Request

Error codes: JOB_NOT_FOUND, JOB_ALREADY_CANCELLED, JOB_CANNOT_CANCEL

Cancellation is accepted only while the provider reports Enqueued, Scheduled, or Awaiting. The provider transition is conditional on that observed state, so a worker that starts or finishes first wins the race and the API returns JOB_CANNOT_CANCEL. The Hangfire lifecycle callback owns the persisted cancellation status and execution history. A successful cancellation does not undo effects already completed by user code. Cancellation also fails when the tracking record has no provider job ID or the provider reports that the state changed.


Recurring Jobs ​

Base path: /api/v1/recurring-jobs

List Recurring Jobs ​

http
GET /api/v1/recurring-jobs?page=1&pageSize=20

Response: 200 OK — PagedResult<RecurringJobDto>

Get Recurring Job ​

http
GET /api/v1/recurring-jobs/{id}

Response: 200 OK — RecurringJobDto | 404 Not Found

Create Recurring Job ​

http
POST /api/v1/recurring-jobs
Content-Type: application/json

{
  "jobId": "daily-cleanup",
  "jobTypeName": "MyApp.Jobs.CleanupJob, MyApp",
  "cronExpression": "0 2 * * *",
  "timeZoneId": "America/Sao_Paulo",
  "queue": "low"
}

Response: 201 Created — RecurringJobDto | 409 Conflict

Creation stores the complete normalized scheduling envelope as Pending before registering it with Hangfire. A retry is allowed only for the same tenant, owner, job type, cron, time zone, and queue; it reuses that original saved intent. After provider work, the handler confirms success only after reading back the exact expected invocation and positively confirming the same durable Pending row. If Hangfire accepted a registration before returning an error, that provider work may execute before confirmation. There is no execution barrier, distributed transaction, or automatic repair guarantee. Confirmed and Legacy schedule duplicates return 409.

Pending schedules cannot be updated, paused, resumed, or deleted by application management commands. Retry the original create request first. Startup registration skips a pending managed key so global defaults cannot replace its saved intent. Legacy rows created before this recovery state have no complete saved envelope; if their provider registration is missing, repair the schedule explicitly rather than reconstructing lost identity, policy, correlation, or retry metadata.

Recurring-job application management uses a per-key PostgreSQL lease and inspects or changes only the targeted Hangfire registration. Pause preserves the existing invocation and saved desired cron; resume restores that same invocation. EF persistence patches management/configuration fields so a concurrent worker's execution counters and timestamps are preserved. Direct low-level Hangfire APIs do not provide these application authorization, lease, and row-patch guarantees.

Update Recurring Job ​

http
PUT /api/v1/recurring-jobs/{id}
Content-Type: application/json

{
  "cronExpression": "0 3 * * *",
  "timeZoneId": "UTC",
  "queue": "default"
}

Response: 200 OK — RecurringJobDto | 404 Not Found

The update changes the cron expression and any supplied time zone or queue. Persistence patches only those configuration fields and management audit fields, preserving execution timestamps and counters if a worker completes at the same time.

Delete Recurring Job ​

http
DELETE /api/v1/recurring-jobs/{id}

Response: 204 No Content | 404 Not Found

Pause Recurring Job ​

http
POST /api/v1/recurring-jobs/{id}/pause

Response: 200 OK | 404 Not Found | 400 Bad Request

This operation records the local paused flag and management audit fields. The Hangfire schedule remains registered with its original serialized invocation and uses Hangfire's Cron.Never() as its effective cron. The saved cron remains the desired schedule, so resume restores it. Pause stops future automatic ticks; an occurrence already enqueued and work already running continue. A manual trigger is an explicit override and can enqueue work while paused.

Provider and database writes are separate transactions. If Hangfire accepts a change and the management record cannot be synchronized, the request fails with a synchronization error. Retry the same operation to reconcile the provider with the current saved schedule. Startup registration honors the managed pause state and envelope identity. There is no guarantee of unattended recovery after a process stops between the provider and database writes.

Resume Recurring Job ​

http
POST /api/v1/recurring-jobs/{id}/resume

Response: 200 OK | 404 Not Found | 400 Bad Request

Trigger Recurring Job ​

http
POST /api/v1/recurring-jobs/{id}/trigger

Immediately executes the job outside its normal schedule.

Response: 200 OK | 404 Not Found


Dead Letter Queue ​

Base path: /api/v1/dead-letter-jobs

List Dead Letter Jobs ​

http
GET /api/v1/dead-letter-jobs?page=1&pageSize=20

Response: 200 OK — PagedResult<DeadLetterJobDto>

Retry Dead Letter Job ​

http
POST /api/v1/dead-letter-jobs/{id}/retry

Re-enqueues the failed job for another attempt.

Response: 200 OK | 404 Not Found | 400 Bad Request

Error codes: JOB_DEADLETTER_NOT_FOUND, JOB_DEADLETTER_ALREADY_RETRIED

Purge Dead Letter Queue ​

http
POST /api/v1/dead-letter-jobs/purge
Content-Type: application/json

{ "retentionDays": 30 }

If retentionDays is null or body is empty, purges all entries.

Response: 200 OK | 400 Bad Request


Error Codes ​

All error codes follow the JOB_{ENTITY}_{SUFFIX} convention:

Error CodeHTTP StatusDescription
JOB_NOT_FOUND404Job not found
JOB_ALREADY_CANCELLED400Job is already cancelled
JOB_CANNOT_CANCEL400Job cannot be cancelled (completed/processing)
JOB_RECURRING_NOT_FOUND404Recurring job not found
JOB_RECURRING_ALREADY_EXISTS409Recurring job ID already taken
JOB_RECURRING_ALREADY_PAUSED400Already paused
JOB_RECURRING_NOT_PAUSED400Not paused
JOB_DEADLETTER_NOT_FOUND404Dead letter entry not found
JOB_DEADLETTER_ALREADY_RETRIED400Already retried

Released under the MIT License.