Create customers

Prev Next

Purpose: Create a customer from the ERP in orderManager and use the assigned customer number for future orders.

Prerequisites: orderManager with the Connect interface and OrderManagerClient configured. First, check in the ERP whether an orderManager customer number is already stored.

Code

using HomagConnect.OrderManager.Contracts.Customers;

var customer = await client.CreateCustomer(new CreateCustomerRequest
{
    CustomerNumberExternal = "ERP-C-10045",
    CustomerName = "Musterkunde",
    Email = "kunde@example.com",
    Locale = Locale.deDE,
    ApiAccess = false
});

Console.WriteLine(customer.CustomerNumber);
POST https://connect.homag.cloud/api/orderManager/customers
Authorization: Basic <base64(SubscriptionId:Berechtigungsschlüssel)>
Accept: application/json
Content-Type: application/json

{
  "customerNumberExternal": "ERP-C-10045",
  "customerName": "Musterkunde",
  "email": "kunde@example.com",
  "locale": "deDE",
  "apiAccess": false
}

201 Created (excerpt):

{
  "customerNumber": "462642",
  "customerNumberExternal": "ERP-C-10045",
  "customerName": "Musterkunde"
}

Save the returned customerNumber alongside your ERP customer number. Then use Read customers instead of creating the customer again. Do not blindly retry a failed write call after a timeout: first check whether the customer has already been created.

Contracts used

Contract Usage
CreateCustomerRequest Input: name, contact details, and external customer number.
Customer Output: created customer, including the orderManager customer number.

Common errors

REST status What to check
400 Bad Request Send valid JSON with Content-Type: application/json.
422 Unprocessable Entity Check the fields and details in ProblemDetails before retrying the call.

Next: Manage customers · View and test endpoint