Job Creation Scenario

Summary

This guide explains how to use the SDM REST API to create a job, upload product data files, and optionally attach media files. The process is designed for integration scenarios where you want to automate the import and processing of product data into Akeneo’s Supplier Data Manager.

Prerequisites

An active user account on the Supplier Data Manager platform

A valid connection token (obtained via the authentication/login endpoint)

A project ID (for which you want to process data)

One or more output formats defined for the project

For details on authentication and project setup, see the official SDM API documentation.

Step 1: Upload a File or Product Data

SDM projects run on files with product data. Two possibilities to send it to the platform:

#Flat file upload (CSV, excel)

This file can have two formats:

  • Excel file, with the xlsx extension, encoded in utf-8, with the data in the first tab
  • CSV file, with csv extension, can use ,, ; or | as a separator and be encoded in utf-8 or ISO 8859-1 / Latin-1

In both cases, the file must have a header in the first line and be composed of at least the columns defined in the template.

To upload the file, you need to make the following request in multipart/form-data format:

POST https://sdm.akeneo.cloud/api/v1/files/

Headers:

Copy

Authorization: Token <YOUR_TOKEN>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

Body:

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="products.csv"
Content-Type: text/csv

[INSERT_BINARY_FILE_CONTENT_HERE]
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="skip_lines"
Content-Type: text/plain

1
----WebKitFormBoundary7MA4YWxkTrZu0gW--

the response contains various information related notably to the status of the file parsing (as this is done asynchronously), and more importantly the id of the uploaded file, which must be kept for later.

{
        "id": 17
        ...
}

Copy

More information on the files endpoint on our API reference

#Sending a JSON payload

The other option to create a file is to send the data in JSON. To do this you need to make the following request:
 

POST https://sdm.akeneo.cloud/api/v1/files/
	{
    	"data": [
    		{"col1": "val1_1", "col2": "val1_2", ...},
    		{"col1": "val2_1", "col2": "val2_2", ...},
    		...
   		]
	}

Copy

The payload is a list of objects, each representing a line with a format "column name" : "column value". All the columns defined in the template must be present. Empty values can be ignored or set with the value null.

As for file sending, the response contains various information including id key which must be kept for later, as we will be using it to create a job.

{
    "id": 17
    ...
}

 

Step 2: Create a Job

 

Now we can launch the processing of your file or data sent. First, you need to create what is called a job and link it to the previously uploaded file or payload sent.

It is necessary to have the id of the project that you want to use. You can use the endpoint to list projects, more information on our API reference

Send this request to create the job:

POST https://sdm.akeneo.cloud/api/v1/jobs/
    {
        "file_id": ${uploaded_file_id},
        "name": "any name you want",
        "project": ${project_id},
        "model_version": 0
    }

 

Copy

The response contains various information, among which the id key which is used to identify the job thus created.

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

Congrats, SDM platform is now processing your data!

 

Step 3: (Optional) Upload and Attach Media Files

As an optional step, media files can be attached to the job. This can happen any time during the job's processing. 

 

Each media file name should be unique for a given job. The link between a product (a line in your flat file or an item in the JSON array) and a media file is established via the filename. For example, if a product contains the property "main_image": "image_show_1.png" , and a file with that name is attached to the job, this media will automatically attached to this product.

Example Request

POST https://sdm.akeneo.cloud/api/v1/media/

Headers:

Authorization: Token <YOUR_TOKEN>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
 

Body:

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="media_file"; filename="example.png"
Content-Type: image/png

[INSERT_BINARY_FILE_CONTENT_HERE]
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="uploaded_for_job"

[JOB_ID]
----WebKitFormBoundary7MA4YWxkTrZu0gW

 

 

Note:
As noted above If a media field (e.g., main_image) is configured for your project and the filename matches a value in your product data, the link will be established automatically. However if this is not the case the job processing will still work, but the link will have to be established manually by the user during the job's execution.