Sending print orders is done through a REST API. Before being able to make requests to the API, you should first authenticate using the credentials received to obtain an authentication token. The token should be included in the "Authorization" header of every subsequent API request:
Authorization: Bearer <your-authentication-token>
The token is valid for one year. A new token is issued on every authentication.
Live API URL https://api.bephoto.be
Authenticate by calling the /user/login endpoint with your credentials:
POST /user/login { "email": "<string>", "password": "<string>" }
Response:
{ "status": 1, "token": "<string>" }
Error Response:
{ "error": "Unauthorized" }
To avoid using a password in your integration, authenticate with an API key by calling /user/loginToken. The key is provided by Bephoto on request, per account:
POST /user/loginToken { "token": "<string>" }
Response:
{ "status": 1, "token": "<string>" }
Error Response:
{ "error": "Unauthorised" }
Create a new order by calling /orders with optional metadata. After creating an order, you will receive a unique idorder, which should be used in subsequent calls:
POST /orders { "metadata": "<string>" }
Response:
{ "status": 1, "order": { "idorder": "<integer>", "datestart": "<timestamp>", "totalorder": "<float>", "totalcost": "<float>", "dateconfirmation": "<timestamp>", "dateprocessed": "<timestamp>", "shippingmethod": "<string>", "metadata": "<string>" } }
Fetch information for an order by calling /orders/{IDORDER}:
GET /orders/{IDORDER}
Response:
{ "status": 1, "order": { "idorder": "<integer>", "datestart": "<timestamp>", "totalorder": "<float>", "totalcost": "<float>", "dateconfirmation": "<timestamp>", "dateprocessed": "<timestamp>", "shippingmethod": "<string>", "metadata": "<string>", "products": [{ "idproduct": "<integer>", "idpaper": "<integer>", "quantity": "<integer>", "size": "<string>" }] } }
The shippingmethod field is PICKUP (collection) or BPOST (delivery to an address). The totalcost field holds the order fees, totalorder the total to pay. A main order also returns its sub-orders (suborders); a sub-order returns the ID of its main order (parent_idorder).
Choose the shipping method by calling /orders/{IDORDER}/shipping/{SHIPPING_METHOD}. Without this call, the order is set to delivery (BPOST). Any other value returns an error.
POST /orders/{IDORDER}/shipping/{SHIPPING_METHOD}
Response:
{ "status": 1 }
Set the delivery address of an order by calling /orders/{IDORDER}/shipping-address. The order is then set to delivery. An order has a single address: create one order per recipient.
POST /orders/{IDORDER}/shipping-address { "nom": "<string>", "prenom": "<string>", "societe": "<string>", "adresse": "<string>", "complement_adresse": "<string>", "cp": "<string>", "localite": "<string>", "pays": "<string>", "email": "<string>" }
Response:
{ "status": 1, "idadrliv": "<integer>" }
Get a list of available print products by calling /products:
GET /products
Response:
{ "status": 1, "products": { "<idformat>": { "idformat": "<integer>", "format": "<string>", "largeur": "<integer>", "hauteur": "<integer>", "prix": { "<idpaper>": "<float>" } } } }
The price returned is the base unit price. Prices are tiered: the unit price decreases with the total quantity ordered for the same product and paper. Use /calculate or /orders/{IDORDER}/price to get the price actually applied.
Add ?include=montage to also get the montages available on your account (pochettes, ID sheets, school layouts), recognisable by idtypeformat = 100. Each layout is a separate product: choose the layout by choosing the product. Send one photo per montage; the lab composes the sheet.
Calculate the price of a list of products, without creating an order, by calling /calculate. The price tier is applied on the quantity of each line:
POST /calculate { "products": "[{ \"idproduct\": <integer>, \"idpaper\": <integer>, \"quantity\": <integer> }]", "shippingmethod": "<string>" }
Response:
{ "products": [{ "idproduct": "<integer>", "idpaper": "<integer>", "quantity": "<integer>", "price": "<float>", "total": "<float>" }], "total_products": "<float>", "total_shipping": "<float>", "total_order": "<float>" }
Add products to your order by sending a POST request to /orders/{IDORDER}/products:
POST /orders/{IDORDER}/products { "idproduct": "<integer>", "idpaper": "<integer>", "quantity": "<integer>", "fileurl": "<string>", "filename": "<string>", "filesize": "<integer>", "backprint": "<string>" }
Several products can be added in a single call:
POST /orders/{IDORDER}/products { "products": [{ "idproduct": "<integer>", "idpaper": "<integer>", "quantity": "<integer>", "fileurl": "<string>", "filename": "<string>", "filesize": "<integer>", "backprint": "<string>" }] }
Response:
{ "status": 1, "products": [{ "idproduct": "<integer>", "idpaper": "<integer>", "quantity": "<integer>", "fileurl": "<string>", "filename": "<string>", "filesize": "<integer>" }] }
To have a batch packed envelope by envelope (school photography), create one sub-order per envelope under the main order by calling /orders/{IDORDER}/suborders:
POST /orders/{IDORDER}/suborders { "label": "<string>" }
Response:
{ "status": 1, "order": { "idorder": "<integer>", "label": "<string>", "parent_idorder": "<integer>" } }
Then add the envelope's photos with /orders/{SUBORDER_ID}/products. Price, shipping and confirmation are handled on the main order only: these calls on a sub-order return an error. Confirming the main order confirms all its sub-orders.
Envelopes are packed in the order the sub-orders were created: create them sorted by class, then by child. The label is printed on the envelope label and, by default, on the back of each photo in the envelope.
An envelope below your account minimum (number of prints and amount) incurs a handling fee, added to the main order's fees. /orders/{IDORDER}/price details these fees per envelope. A sub-order's totalorder stays at 0 until the main order is confirmed, which then records the envelope's amount.
Before confirming, get the unit price applied to each product of the order by calling /orders/{IDORDER}/price. Quantities of the same product and paper are added up to determine the tier:
POST /orders/{IDORDER}/price {}
Response:
{ "status": 1, "products": [{ "idformat": "<integer>", "idpapier": "<integer>", "prix": "<float>", "quantite": "<integer>" }], "suborders": [{ "idorder": "<integer>", "label": "<string>", "prints": "<integer>", "total": "<float>", "fee": "<float>" }] }
The suborders field details each envelope: number of prints, amount and handling fee, if any.
Once all products are added, close the order by calling /orders/{IDORDER}/close:
A confirmed order can no longer be modified.
POST /orders/{IDORDER}/close {}
Response:
{ "status": 1, "total_order": "<float>", "products": [{ "idformat": "<integer>", "idpapier": "<integer>", "prix": "<float>", "quantite": "<integer>" }] }
One school, one envelope per child, delivered to the school:
POST /orders Create the school's main order.POST /orders/{IDORDER}/shipping-address Set the school's address.POST /orders/{IDORDER}/suborders Create one sub-order per child, sorted by class, then by child.POST /orders/{SUBORDER_ID}/products Add each child's photos: prints, pochettes, ID sheets.POST /orders/{IDORDER}/price Check the price and the fees per envelope.POST /orders/{IDORDER}/close Confirm: every envelope goes into production.For delivery to a parent's home, create a separate order with its own delivery address.