Monitoring SDM jobs

Summary

This article explains how to use the Supplier Data Manager (SDM) REST API to track the progress of a job, list jobs in your organization, cancel a job, and retrieve job output data in JSON format.

All requests require an Authorization: Token <YOUR_TOKEN> header. For authentication setup, see Getting started with the API.

Get the status of an SDM job

To check the current status of a Supplier Data Manager job, call the job detail endpoint:

GET https://sdm.akeneo.cloud/api/v1/jobs/{job_id}/

Replace {job_id} with the UUID returned when the job was created.

The response includes a status field with one of the following values:

Status Meaning
running The job is processing. Poll again in a few seconds.
done The job has completed successfully. You can now retrieve the output data.
error An error occurred. Check the message field in the response for details.
pending The job is waiting for an action on your side before it can continue.
cancelled The job was cancelled. It has stopped for good and can't be resumed: create a new job to start again.

Example response:

{
    "status": "running",
    "step": {
        "id": 1
    }
}

When status is error, the message field in the response contains a description of the failure.

Note: After a step is validated, the job can stay pending on that step for a short time while SDM saves the step results. The job is then not waiting for you. To know if SDM is still working, use the progress endpoint below.

Follow the progress of an SDM job

To see each step of a job and where the current step stands, call the job progress endpoint:

GET https://sdm.akeneo.cloud/api/v1/jobs/{job_id}/progress/

Among other fields, the response includes a status field for the job and a steps list:

Status Meaning
in_progress SDM is working on the job. This includes a validated step that is still saving its results.
pending The job is waiting for an action on your side before it can continue.
completed The job has completed successfully.
error An error occurred in one of the steps.
cancelled The job was cancelled.

Note: This endpoint uses in_progress and completed where the job status endpoint uses running and done. When a validated step still saves its results, this endpoint reports in_progress, and the job status endpoint reports pending.

Each entry in steps has a type field, for example mapping or extraction. Use type, not name, to identify a step, because you can rename a step.

While SDM works on the current step, the entry of that step in steps also has these fields:

Field Description
phase preparing: the step loads its products. processing: the step works on the products. finalizing: the step saves its results.
processed_products The number of products that the step has processed. For an Extraction step, see the note below.
total_products The number of products that the step processes. 0 means that the step does not give a count. For an Extraction step, see the note below.

Note: When type is extraction, processed_products and total_products count attribute values, not products: one value for each attribute that the step extracts for each product. For example, 4 products with 25 attributes to extract each give a total of 100.

These fields are present only if your access includes the current step. For example, a supplier portal sees them only for the steps up to its last accessible step.

To see how far the current step is, use processed_products and total_products. The progress, progress_current and progress_total fields of a step come from an internal task and do not give these counts.

Example response (extract):

{
    "status": "in_progress",
    "steps": [
        {
            "name": "Mapping",
            "type": "mapping",
            "status": "in_progress",
            "phase": "processing",
            "processed_products": 1000,
            "total_products": 3000
        },
        {
            "name": "Extraction",
            "type": "extraction",
            "status": "not_started"
        }
    ]
}

Retrieve the list of SDM jobs

To retrieve all jobs created in your organization, call:

GET https://sdm.akeneo.cloud/api/v1/jobs/

Filter parameters

Narrow results by adding query parameters:

Parameter Description
status Filter by job status: running, done, error, pending, or cancelled
project Filter by project ID
created_after Return only jobs created after this date (ISO 8601 format)
created_before Return only jobs created before this date (ISO 8601 format)
archive_view Filter by archive state: active (jobs that are not archived), archived (archived jobs only), or all. When omitted, all jobs are returned

Example — all completed jobs for project 17 created after 1 January 2022:

GET https://sdm.akeneo.cloud/api/v1/jobs/?status=done&project=17&created_after=2022-01-01T00:00:00Z

Response format

Results are paginated. The default page size is 25. Use the page and page_size query parameters to control pagination.

{
    "count": 100,
    "next": "https://sdm.akeneo.cloud/api/v1/jobs/?page=2",
    "previous": null,
    "results": [
        {
            "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "name": "Job 1",
            "status": "done",
            "can_cancel": false,
            "creation_date": "2022-04-14T08:48:37.109159Z",
            "completion_date": "2022-04-17T09:53:32.12Z"
        }
    ]
}

next and previous contain the URL for the next and previous page respectively, or null if no such page exists.

Each job also has two archive fields:

  • archive_status: null if the job was never archived. Otherwise one of archiving, archived, restoring, restored, archive_failed or restore_failed.
  • archived_at: the date the job was archived, or null.

Cancel an SDM job

To stop a job that hasn't finished yet, call:

POST https://sdm.akeneo.cloud/api/v1/jobs/{job_id}/cancel/

With your API token, you can cancel any job of your organization if you are an organization admin, and otherwise the jobs you created. A running step is stopped and the job gets the cancelled status. It can't be resumed: create a new job to start again.

Every job in the API responses has a can_cancel field. It is true when this call is allowed for you, so you can check it before cancelling.

When the job's state doesn't allow a cancel, the response is 409 Conflict with a code:

Code Meaning
job_moving_to_next_step The job is moving to its next step. Try again once it's finished.
job_reading_file The job is still reading its file. Try again once it's finished.
job_already_cancelled The job is already cancelled.
job_done The job is already finished.
job_failed The job failed, so it can't be cancelled.
job_past_supplier_steps The job has moved past the supplier's steps, or its step was deleted from the project (supplier access only).

Example response:

{
    "detail": "The job is moving to its next step",
    "code": "job_moving_to_next_step"
}

A 403 response means you are neither an organization admin nor the job's creator. A 404 response means the job doesn't exist in your organization.

Once a job is cancelled, every request on one of its steps, whether it reads or changes it, and any request to send it back to a step, answers 409 Conflict with the code job_cancelled. You can still read the job itself, download its files and delete it.

Work with archived jobs

This feature is being rolled out progressively, so it may not be available in your space yet.

An archived job is still returned in your list of jobs, but its data can't be accessed until you restore it.

Restore an archived job

To bring an archived job's data back, call:

POST https://sdm.akeneo.cloud/api/v1/jobs/{job_id}/restore/

Only members of the job's organization can restore it. The restore runs in the background, so the response is 202 Accepted with a task ID:

{
    "task_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

Poll the task until it finishes:

GET https://sdm.akeneo.cloud/api/v1/tasks/{task_id}/status/

If you ask again while a restore is running, you get the same task back. When the restore is done, the job's archive_status is restored.

Status code Code Meaning
409 job_not_archived The job isn't archived, so there is nothing to restore.
409 restore_failed_admin_only The job's last restore failed. Contact support to get the job back.
409 job_archiving, job_restoring or job_purging The job's data is being moved. Try again once it's finished.
403 archiving_disabled Archiving isn't available for this job.

Requests on an archived job

Requests on the job's data are refused while the job is archived or while it is being archived or restored:

Status code Code Meaning
410 job_archived The job is archived. Restore it to access its data.
410 job_restore_failed The last restore failed. Contact support to get the job back.
409 job_archiving The job is being archived. Try again once it's finished.
409 job_restoring The job is being restored. Try again once it's finished.
409 job_purging The job's data is being cleared after archiving. Try again once it's finished.

Example response:

{
    "code": "job_archived",
    "detail": "This job is archived. Restore it from the job list to access its data.",
    "job_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

Retrieve SDM job output data in JSON format

Once an SDM job has status: done, you can retrieve the output data in JSON format:

GET https://sdm.akeneo.cloud/api/v1/jobs/{job_id}/data/{output_format_id}/

Replace {job_id} with the job UUID and {output_format_id} with the ID of the output format configured for the project.

Example response:

[
    {
        "col1": "val1_1",
        "col2": "val2_1"
    }
]

The response is an array of objects, one per row of the output dataset. Each object's keys are the column names. Empty columns are omitted from the response.