Conventions
Every operation follows the same rules. Learn them once and every resource reads the same way.
Address and paths
-
One host,
https://api.myleapp.fr, and no version in the path:GET /organizations/{id}/products. How the API evolves is in Versioning. -
Path segments are American English, lowercase kebab-case, plural
for collections:
/delivery-notes. -
An organization's data lives under
/organizations/{id};{id}is always the organization's id. Other ids are named:/organizations/{id}/products/{productId}. -
Your own data lives under
/me:GET /meis the account the key acts as. - No file extension: the format is chosen with
Accept.
Methods
| Intent | Form | Success |
|---|---|---|
| List | GET /organizations/{id}/products | 200, a list |
| Read | GET …/products/{productId} | 200 |
| Create | POST /organizations/{id}/products | 201, Location, the resource |
| Change | PATCH …/products/{productId}, a JSON merge patch | 200, the resource |
| Delete | DELETE …/products/{productId} | 204, no body |
| Business action | POST …/invoices/{invoiceId}/validate | 200, the resource |
A GET never changes anything.
Ids
-
An id is an opaque string,
<kind>_<uuid>:product_2ab4c6e8-…,organization_7f2c41d0-…,deliveryNote_9f3c…. Store it as a string; do not parse it. -
A reference to another resource is
<kind>Id(companyId), or an embedded summary{"id", "object", …}. -
Some ids were first spelled differently in Myle
(
organisation_…,exercice_……). The API always answers the English spelling and accepts both as input, so an id copied from the Myle app works. Store the spelling the API answers.
object
Every resource carries object, its kind:
"object": "product". It is the id's prefix, spelled out.
Money, quantities and rates
Money is an object with a decimal string, never a floating-point number:
CLI
#!/usr/bin/env bash
# conventions-money: the myle CLI (key from `myle login` or MYLE_API_KEY).
# Money is a decimal string and its currency: jq keeps the string, never a float.
myle products retrieve product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d \
--organization organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
| jq -r '.unitPrice // empty | "\(.amount) \(.currency)"' # 45.00 EUR
JSON
"unitPrice": { "amount": "45.00", "currency": "EUR" }
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
const product = await myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').products.get('product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d');
// Money is a decimal string and its currency: hand it to a decimal library, never to a float.
if (product.unitPrice !== null) {
console.log(product.unitPrice.amount, product.unitPrice.currency); // 45.00 EUR
}
Python
from decimal import Decimal
from myle import Myle
myle = Myle()
product = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products.get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
# Money is a decimal string and its currency: read it as a Decimal, never as a float.
if product.unit_price is not None:
price = Decimal(product.unit_price.amount)
print(price * 2, product.unit_price.currency) # 90.00 EUR
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
org := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d")
product, err := org.Products.Get(context.Background(), "product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
if err != nil {
log.Fatal(err)
}
// Money is a decimal string and its currency: hand it to a decimal library, never to a float.
if product.UnitPrice != nil {
fmt.Println(product.UnitPrice.Amount, product.UnitPrice.Currency) // 45.00 EUR
}
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Product;
import java.math.BigDecimal;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
Product product = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products().get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d");
// Money is a decimal string and its currency: read it as a BigDecimal, never as a double.
if (product.unitPrice() != null) {
BigDecimal price = new BigDecimal(product.unitPrice().amount());
System.out.println(price.multiply(BigDecimal.valueOf(2)) + " " + product.unitPrice().currency()); // 90.00 EUR
}
}
}
Scala
import fr.myleapp.myle.MyleClient
object ConventionsMoney {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
val product = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products.get("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d")
// Money is a decimal string and its currency: hand it to BigDecimal, never to a Double.
for (price <- product.unitPrice) {
println(s"${price.amount} ${price.currency}") // 45.00 EUR
}
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
$product = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->products->get('product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d');
// Money is a decimal string and its currency: hand it to a decimal library (bcmath, brick/math), never to a float.
if ($product->unitPrice !== null) {
echo $product->unitPrice->amount, ' ', $product->unitPrice->currency, "\n"; // 45.00 EUR
}
C#
using Myle;
using var client = new MyleClient();
var product = await client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products.GetAsync("product_2ab4c6e8-1f3d-4a5b-8c7d-9e0f1a2b3c4d");
// Money is a decimal string and its currency: hand it to decimal, never to a double.
if (product.UnitPrice is not null)
{
Console.WriteLine($"{product.UnitPrice.Amount} {product.UnitPrice.Currency}"); // 45.00 EUR
}
Quantities and rates are decimal strings too:
"quantity": "12.5", "vatRate": "5.5".
Read them with a decimal type (Decimal in Python,
BigDecimal in Java, a decimal library in JavaScript),
never as a float.
Dates and instants
- A calendar date is
YYYY-MM-DD:"issueDate": "2026-11-21". -
An instant is RFC 3339 in UTC:
"updatedAt": "2026-11-21T09:14:03Z". Every resource hascreatedAtandupdatedAt.
Enums grow
Enum values are SCREAMING_SNAKE_CASE (ACTIVE,
DRAFT) and listed in the reference. A new value can
appear at any time: tolerate a value you do not know,
treat it as “other”, never fail on it.
null and absent
-
In a response, an empty optional field is
null, never left out: every response of a resource has the same keys. - In a request, an absent field means “not provided”.
-
In a
PATCH,nullclears a field and an absent member leaves it as it is (see Writes). -
Booleans read as assertions:
isPrimary,hasAttachments.
Unknown fields
New fields are added to responses without notice. Ignore the fields you do not know; do not reject a response because of them.
Headers
What you send
| Header | Use |
|---|---|
Authorization: Bearer <key> | Your API key (Authentication). |
Myle-API-Version: YYYY-MM-DD | The contract you built against; optional (Versioning). |
Myle-Client: <name>/<version> | Names your integration: my-export/1.0.0, sdk-js/1.2.0. |
Idempotency-Key | On a POST, makes a retry safe (Writes). |
If-Match | On a PATCH or DELETE, refuses to overwrite a change you have not seen. |
Accept-Language: fr or en | The language of error messages; English when absent. |
Content-Type | application/json; application/merge-patch+json for a PATCH. |
traceparent | W3C Trace Context; Myle continues your trace. |
What you get
| Header | When |
|---|---|
Myle-Request-Id | Always: the request's id in Myle's logs, for support. |
RateLimit-Policy, RateLimit | On every response to a key, errors included (Rate limits). |
Retry-After | On 429 and 503: seconds to wait. |
ETag | On a single resource. |
Location | On 201: the new resource's path. |
Content-Language | On an error: the language of its message. |
Myle-Idempotent-Replayed: true | When a response is replayed for an Idempotency-Key. |
Myle-API-Version, Deprecation, Sunset, Link | When an older behavior was served (Versioning). |
Myle's own headers start with Myle-; standard headers keep their names.