Technical best practice - Eulerian Marketing Platform API
Best practice - Eulerian Marketing Platform API
1. Authentication and security
API token
The Eulerian API uses a Bearer token sent in the HTTP Authorization header.
Authorization: Bearer <votre_token_api>
Best practice:
- Never hard-code the token in your source code. Use an environment variable or a secrets vault (Vault, AWS Secrets Manager and so on).
- Restrict tokens to the permissions strictly needed (principle of least privilege).
- Do not write authorisation headers to your application log files.
HTTPS required
Every request must go over HTTPS.
2. General integration principles
URL structure
https://<votre_domaine_eulerian>/ea/v2/<endpoint>
The domain is specific to your Eulerian account (e.g. dem.api.eulerian.com).
Standard headers
Content-Type: application/json
Accept: application/json
Authorization: Bearer <token>
Rate limiting
- Respect the rate limits set by Eulerian (see the documentation for your contract).
- Implement exponential backoff when you receive a
429 Too Many Requestsresponse. - Do not parallelise calls excessively: prefer ordered processing queues.
Idempotence
- For job creation requests, use a business identifier (a client-side
jobrun_id) to avoid duplicates when you retry. - Check whether a similar job already exists before creating a new one.
3. Batch Reporting · Overview
Batch Reporting is the main way to extract large volumes of analytics data from the Eulerian platform. Unlike synchronous requests (limited to small volumes), Batch works asynchronously:
- You submit a report request → Eulerian creates a job and returns a
jobrun_id. - You check the job’s status at regular intervals (polling).
- Once the job is finished (
DONE), you download the results file.
When should you use Batch Reporting?
| Use case | Recommendation |
|---|---|
| Extracting data over more than 7 days | Batch required |
| More than 10,000 rows expected | Batch recommended |
| Scheduled processing / nightly ETL | Batch |
| Real-time dashboards (< 1,000 rows) | Synchronous API |
| Tests / ad hoc exploration | Synchronous API |
4. Life cycle of a Batch job
[SUBMIT] → PENDING → RUNNING → DONE
↘ FAILED
↘ EXPIRED
| Status | Description |
|---|---|
PENDING | Job queued, not yet processed |
RUNNING | Being processed on the Eulerian side |
DONE | Report ready to download |
FAILED | Error during processing (see the error field) |
EXPIRED | The results file was not downloaded in time |
How long results are kept: the files Eulerian generates are available for a limited time (usually 24 to 72 hours). Download and archive the results as soon as the status is DONE.
5. Polling and status handling
Status endpoint
GET /ea/v2/report/batch/status.json?jobrun-id={jobrun_id}
Recommended polling strategy
Never poll too aggressively: it uses up your API call quota for nothing.
Suggested interval:
| Time since submission | Polling interval |
|---|---|
| 0 – 2 min | Every 30 seconds |
| 2 – 10 min | Every 60 seconds |
| 10 – 60 min | Every 5 minutes |
| > 60 min | Every 15 minutes |
Maximum timeout: set an overall timeout (e.g. 4 hours). Beyond it, treat the job as failed and raise an alert.
Implementation:
- Store the
jobrun_idpersistently (database, file) so that polling can resume after your application restarts. - Do not start a new job if an identical one is already in progress (
PENDINGorRUNNING).
Example polling loop (pseudo-code)
ATTENDRE 30 secondes
TANT QUE timeout non atteint :
statut = GET /batch/status.json?jobrun-id{jobrun_id}
SI statut == DONE → télécharger résultat → FIN
SI statut == FAILED → logger erreur → FIN
SI statut == EXPIRED → relancer job → FIN
ATTENDRE intervalle_adaptatif()
SINON → alerter équipe ops
7. Retrieving and processing the results
Download endpoint
GET /ea/v2/report/batch/download.json?jobrun-id={jobrun_id}
The response contains either the file itself, streamed, or a temporary download URL.
Download best practice
- Stream the download rather than loading the whole file into memory (files can reach several hundred MB).
- Archive the raw file before any processing (so that processing stays idempotent).
Processing the CSV
- Always specify
UTF-8encoding when opening the file. - Handle header rows dynamically (columns can change).
- Check the number of columns in each row before inserting it into the database.
- Handle null values and empty strings explicitly (do not confuse them with
0).
Handling large volumes
For files over 100 MB:
- Process line by line as a stream (never load everything into RAM).
- Insert into the database in batches of 1,000 to 5,000 rows (bulk insert).
- Implement error recovery that records the last line processed.
8. Error handling
HTTP codes to handle
| Code | Meaning | Recommended action |
|---|---|---|
200 | Success | Normal processing |
400 | Invalid request | Log the response, fix the parameters |
401 | Invalid/expired token | Renew the token, raise an alert |
403 | Insufficient permissions | Check the token’s rights |
404 | Job not found | The job has expired or the ID is wrong |
429 | Rate limit reached | Exponential backoff (min. 60s) |
500 | Eulerian server error | Retry after a delay, contact support if it persists |
503 | Service unavailable | Retry with backoff, keep an eye on Eulerian’s status |
Retry strategy
Tentative 1 : immédiate
Tentative 2 : +5 secondes
Tentative 3 : +15 secondes
Tentative 4 : +60 secondes
Tentative 5 : +300 secondes
Au-delà : alerter et abandonner
Never retry on 400, 401 or 403 errors (client errors: fix the problem first).
Logging
- Always log: timestamp, endpoint called, HTTP code received,
job_id, request duration. - Never log the API token or end users’ personal data.
- Keep error logs for at least 30 days to make debugging easier.
9. Go-live checklist
Security
- API token stored in an environment variable (never hard-coded)
- HTTPS enforced on every call
- Logs contain neither the token nor personal data
Robustness
- Retry with exponential backoff implemented
- Overall polling timeout set (recommended: 4 hours)
-
jobrun_idpersisted so you can resume after a crash - Status checked before restarting an identical job
Performance
- Date ranges split into windows of ≤ 90 days
- Column selection limited to what is strictly needed
- Download streamed (the file is never loaded whole into memory)
- Database insertion in batches (bulk insert)
Monitoring
- Alerts on jobs in
FAILEDorKILLED - Alerts on
401/403errors (expired token) - Dashboard tracking job processing times
- Raw files archived before processing
Tests
- Tests on short date ranges before going live
- Output CSV format validated (number of columns, encoding)
- Behaviour tested on a
429(rate limiting) - Recovery tested after an interruption during polling
In this section
1 page