Démarrer
Créez une clé, faites un premier appel, lisez la réponse, faites le
suivant. Il vous faut un compte Myle et un terminal avec
curl.
1. Créer une clé
Myle a deux sortes de clés (détails dans Authentification). Pour une intégration qui tourne seule, un serveur ou une tâche de nuit, créez une clé d'organisation : elle agit sous son propre compte robot et continue de fonctionner quand la personne qui l'a créée quitte l'organisation.
- Connectez-vous à Myle sur le web, app.myleapp.fr, et ouvrez l'organisation dans laquelle l'intégration travaillera.
-
Dans les paramètres de l'organisation, ouvrez « Clés d'API ». Il
faut le droit
API_KEYS_MANAGE; si l'écran n'apparaît pas, demandez à un membre qui gère l'organisation. - Créez une clé et donnez-lui un nom qui dit ce qui l'utilise, par exemple « Export comptable Sage ». Ce nom apparaît comme l'auteur de tout ce que la clé écrit.
-
Choisissez ce que la clé peut faire, avec le même éditeur que pour
les membres : un rôle, des droits, et une restriction par étiquettes
si besoin. Ne donnez que ce dont l'intégration a besoin ; pour ce
guide,
ARTICLES_LIST(voir les articles). Vous ne pouvez donner que des droits que vous avez vous-même. - Choisissez quand elle expire : 30 jours, 90 jours, 1 an (par défaut) ou jamais.
- Confirmez avec votre clé d'accès (passkey) : Myle la demande avant de créer une clé.
- Copiez le jeton. Il n'est affiché qu'une fois : Myle n'en garde qu'une empreinte. Si vous le perdez, renouvelez la clé pour en obtenir un nouveau.
Pour essayer l'API avec vos propres droits, créez plutôt une clé utilisateur dans « Mon compte », sous « Mes clés d'API ». Elle agit en votre nom, dans vos organisations.
Gardez le jeton dans les secrets de votre serveur, ici une variable d'environnement :
CLI
#!/usr/bin/env bash
# getting-started-env-key: the myle CLI (key from `myle login` or MYLE_API_KEY).
# The CLI reads MYLE_API_KEY too; or store the key once for the project, read on stdin without echo.
myle login --interactive
Shell
export MYLE_API_KEY='myleOrganizationKey_01JD3QF8Z6K4W1Y9X2T5C7N3BA_4fT9q…_k2P9xQ'
Une clé est un mot de passe. Ne la mettez jamais dans une page web, une application mobile, une adresse URL ou un dépôt de code : appelez l'API depuis votre serveur.
2. Premier appel : qui suis-je ?
CLI
#!/usr/bin/env bash
# getting-started-whoami: the myle CLI (key from `myle login` or MYLE_API_KEY).
# The CLI sends Myle-Client: cli/<version>; -H names your integration and its version instead.
myle me -H 'Myle-Client: my-export/1.0.0' | jq -r '[.id, .email, .firstName] | @tsv'
HTTP (curl)
curl https://api.myleapp.fr/me \
-H "Authorization: Bearer $MYLE_API_KEY" \
-H "Myle-Client: my-export/1.0.0"
TypeScript
import { Myle } from '@myleapp/myle';
// The key comes from MYLE_API_KEY. myleClient (optional) names your integration and its version.
const myle = new Myle({ myleClient: 'my-export/1.0.0' });
const me = await myle.me.get();
console.log(me.id, me.email, me.firstName);
Python
from myle import Myle
# The key comes from MYLE_API_KEY. myle_client (optional) names your integration and its version.
myle = Myle(myle_client="my-export/1.0.0")
me = myle.me.get()
print(me.id, me.email, me.first_name)
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
// The key comes from MYLE_API_KEY. WithMyleClient (optional) names your integration and its version.
client := myle.NewClient(myle.WithMyleClient("my-export/1.0.0"))
me, err := client.Me.Get(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(me.ID, me.Email, me.FirstName)
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.User;
public class Example {
public static void main(String[] args) {
// The key comes from MYLE_API_KEY. myleClient (optional) names your integration and its version.
MyleClient client = MyleClient.builder().myleClient("my-export/1.0.0").build();
User me = client.me().get();
System.out.println(me.id() + " " + me.email() + " " + me.firstName());
}
}
Scala
import fr.myleapp.myle.{MyleClient, MyleConfig}
object GettingStartedWhoami {
def main(args: Array[String]): Unit = {
// The key comes from MYLE_API_KEY. myleClient (optional) names your integration and its version.
val myle = MyleClient(MyleConfig(myleClient = Some("my-export/1.0.0")))
val me = myle.me.get()
println(s"${me.id} ${me.email} ${me.firstName}")
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
// The key comes from MYLE_API_KEY. myleClient (optional) names your integration and its version.
$myle = new Client(myleClient: 'my-export/1.0.0');
$me = $myle->me->get();
echo $me->id, ' ', $me->email, ' ', $me->firstName, "\n";
C#
using Myle;
// The key comes from MYLE_API_KEY. MyleClientHeader (optional) names your integration and its version.
using var client = new MyleClient(new MyleClientOptions { MyleClientHeader = "my-export/1.0.0" });
var me = await client.Me.GetAsync();
Console.WriteLine($"{me.Id} {me.Email} {me.FirstName}");
Myle-Client est facultatif : il nomme votre intégration
et sa version, pour que ses appels se distinguent dans les
statistiques d'usage de Myle.
3. La réponse
HTTP
HTTP/1.1 200 OK
Content-Type: application/json
Myle-Request-Id: 01M803CAJ14DSK72C4MKMWBPT7
RateLimit-Policy: "read";q=600;w=60
RateLimit: "read";r=599;t=60
{
"id": "user_5b1e9c2a-…",
"object": "user",
"email": "apikey-01JD3QF8…@robots.myleapp.invalid",
"firstName": "Export comptable Sage",
"lastName": "",
"createdAt": "2026-11-21T09:14:03Z"
}
-
Avec une clé d'organisation,
/meest le compte robot de la clé : il porte le nom de la clé, son adresse ne reçoit jamais de courrier. Avec une clé utilisateur, c'est vous. -
Chaque ressource porte son
id, préfixé par sa sorte (user_…), etobject, cette même sorte en toutes lettres. Les clés JSON sont en camelCase ; les instants en RFC 3339, en UTC. Voir Conventions. -
Myle-Request-Ididentifie la requête dans les journaux de Myle : citez-le quand vous écrivez à l'assistance. -
RateLimit-PolicyetRateLimitdisent quel quota a été compté (read: 600 requêtes par minute) et ce qu'il en reste. Voir Limites de débit.
4. L'appel suivant : votre organisation et ses articles
Toute opération sur les données d'une organisation se trouve sous
/organizations/{id}. L'identifiant de l'organisation est
dans la barre d'adresse quand vous utilisez Myle sur le web :
app.myleapp.fr/organisations/organisation_7f2c41d0-…/….
L'API accepte cette orthographe et répond avec l'orthographe
américaine, organization_7f2c41d0-….
CLI
#!/usr/bin/env bash
# getting-started-organization: the myle CLI (key from `myle login` or MYLE_API_KEY).
myle organizations retrieve organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
| jq -r '[.name, .siren, .vatNumber] | @tsv'
HTTP (curl)
curl https://api.myleapp.fr/organizations/organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
-H "Authorization: Bearer $MYLE_API_KEY"
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
// organization(id) sends nothing: it scopes the calls made through it.
const organization = await myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').get();
console.log(organization.name, organization.siren, organization.vatNumber);
Python
from myle import Myle
myle = Myle()
# organization(id) sends nothing: it scopes the calls made through it.
organization = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").get()
print(organization.name, organization.siren, organization.vat_number)
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
// Organization(id) sends nothing: it scopes the calls made through it.
organization, err := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Get(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(organization.Name, text(organization.Siren), text(organization.VatNumber))
}
// text is a member that may be null (a pointer) as text: "" for null.
func text(s *string) string {
if s == nil {
return ""
}
return *s
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Organization;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
// organization(id) sends nothing: it scopes the calls made through it.
Organization organization = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").get();
System.out.println(organization.name() + " " + organization.siren() + " " + organization.vatNumber());
}
}
Scala
import fr.myleapp.myle.MyleClient
object GettingStartedOrganization {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
// organization(id) sends nothing: it scopes the calls made through it.
val organization = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").get()
println(s"${organization.name} ${organization.siren.getOrElse("")} ${organization.vatNumber.getOrElse("")}")
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
// organization(id) sends nothing: it scopes the calls made through it.
$organization = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->get();
echo $organization->name, ' ', $organization->siren, ' ', $organization->vatNumber, "\n";
C#
using Myle;
using var client = new MyleClient();
// Organization(id) sends nothing: it scopes the calls made through it.
var organization = await client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").GetAsync();
Console.WriteLine($"{organization.Name} {organization.Siren} {organization.VatNumber}");
JSON
{
"id": "organization_7f2c41d0-…",
"object": "organization",
"name": "SARL Les Prés Verts",
"siren": "123456789",
"vatNumber": "FR12123456789",
"createdAt": "2024-02-12T08:30:00Z",
"updatedAt": "2026-10-03T15:12:40Z"
}
Puis le catalogue, deux articles à la fois :
CLI
#!/usr/bin/env bash
# getting-started-products-page: the myle CLI (key from `myle login` or MYLE_API_KEY).
# One page of two; --all follows every page.
page=$(myle products list --organization organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d --limit 2)
jq -r '.data[] | [.number, .name, .unitPrice.amount] | @tsv' <<<"$page"
jq -r 'if .nextCursor then "more pages follow" else "last page" end' <<<"$page"
HTTP (curl)
curl "https://api.myleapp.fr/organizations/organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d/products?limit=2" \
-H "Authorization: Bearer $MYLE_API_KEY"
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
const products = myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').products;
// One page of two; iterate list() itself to follow every page.
const page = await products.list({ limit: 2 }).firstPage();
for (const product of page.data) {
console.log(product.number, product.name, product.unitPrice?.amount);
}
console.log(page.hasMore ? 'more pages follow' : 'last page');
Python
from myle import Myle
myle = Myle()
products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
# One page of two; iterate list() itself to follow every page.
page = products.list(limit=2).first_page()
for product in page.data:
print(product.number, product.name, product.unit_price.amount if product.unit_price else None)
print("more pages follow" if page.has_more else "last page")
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
products := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products
// One page of two; range over List(…).All() to follow every page.
page, err := products.List(context.Background(), &myle.ProductListParams{Limit: myle.Int(2)}).FirstPage()
if err != nil {
log.Fatal(err)
}
for _, product := range page.Data {
price := ""
if product.UnitPrice != nil {
price = product.UnitPrice.Amount
}
fmt.Println(product.Number, product.Name, price)
}
if page.HasMore() {
fmt.Println("more pages follow")
} else {
fmt.Println("last page")
}
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Page;
import fr.myleapp.myle.Product;
import fr.myleapp.myle.ProductListParams;
import fr.myleapp.myle.Products;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
Products products = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products();
// One page of two; iterate list() itself to follow every page.
Page<Product> page = products.list(ProductListParams.builder().limit(2).build()).firstPage();
for (Product product : page.data()) {
String amount = product.unitPrice() != null ? product.unitPrice().amount() : null;
System.out.println(product.number() + " " + product.name() + " " + amount);
}
System.out.println(page.hasMore() ? "more pages follow" : "last page");
}
}
Scala
import fr.myleapp.myle.MyleClient
import fr.myleapp.myle.models.ListProductsParams
object GettingStartedProductsPage {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
val products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
// One page of two; iterate list() itself to follow every page.
val page = products.list(ListProductsParams(limit = Some(2))).firstPage()
for (product <- page.data) {
println(s"${product.number} ${product.name} ${product.unitPrice.map(_.amount).getOrElse("")}")
}
println(if (page.hasMore) "more pages follow" else "last page")
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
$products = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->products;
// One page of two; iterate list() itself to follow every page.
$page = $products->list(limit: 2)->firstPage();
foreach ($page->data as $product) {
echo $product->number, ' ', $product->name, ' ', $product->unitPrice?->amount, "\n";
}
echo $page->hasMore() ? 'more pages follow' : 'last page', "\n";
C#
using Myle;
using var client = new MyleClient();
var products = client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products;
// One page of two; await foreach over ListAsync itself to follow every page.
var page = await products.ListAsync(new ProductListParams { Limit = 2 }).FirstPageAsync();
foreach (var product in page.Data)
{
Console.WriteLine($"{product.Number} {product.Name} {product.UnitPrice?.Amount}");
}
Console.WriteLine(page.HasMore ? "more pages follow" : "last page");
JSON
{
"data": [
{
"id": "product_2ab4c6e8-…",
"object": "product",
"number": "A0012",
"name": "Ensilage maïs",
"status": "ACTIVE",
"unitPrice": { "amount": "45.00", "currency": "EUR" },
"costPrice": null,
"vatRate": "20",
"accountingNumber": "706000",
"barcodes": [],
"tags": ["Prestations"],
"createdAt": "2026-03-02T10:21:44Z",
"updatedAt": "2026-10-18T07:55:02Z"
},
{ "id": "product_9d0f…", "object": "product", "…": "…" }
],
"nextCursor": "eyJrIjoi…"
}
Les montants sont des chaînes décimales, jamais des nombres. Pour la
page suivante, renvoyez nextCursor en
cursor ; la dernière page n'a pas de curseur. Voir
Pagination.
Une opération que la référence ne liste pas encore n'est pas publiée : sa forme peut encore changer.
5. Quand quelque chose ne va pas
Sans l'en-tête Authorization :
HTTP
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Content-Language: en
WWW-Authenticate: Bearer realm="myle"
Myle-Request-Id: 01M803DQ7T5XK2W9H4NB8RZC3E
{
"code": "auth.credential.missing",
"context": {},
"error": "Authentication required.",
"request_id": "01M803DQ7T5XK2W9H4NB8RZC3E"
}
Votre programme décide d'après code ;
error s'adresse à une personne, en anglais par défaut ou
en français avec Accept-Language: fr (« Authentification
requise. »). Sans le droit ARTICLES_LIST, les articles
répondent 403 auth.right.missing avec
{"right": "ARTICLES_LIST"}. Voir
Erreurs.