Site measurement (Aufmaß) → customer request, order or project with draft quote
A measurement tool sends what was recorded on site. The craft business picks what it becomes in Craftivo: a customer request on the board, an order, or a project with a draft quote built from rooms, measurement rows and the business's own article numbers.
Satz zum Kopieren
Gib diesen Satz Deinem Claude Code oder Codex. Die KI liest das Rezept und baut Dein Tool um.
Lies https://www.craftivo.app/developers/recipes/aufmass.md und bau mein Aufmaß-Tool so um, dass es jede Aufnahme an Craftivo sendet. Beim Senden wähle ich: Kundenanfrage, Auftrag oder Projekt mit Angebotsentwurf. Teste zuerst mit dem Schlüssel meines Übungskontos.$CRAFTIVO_API_URL = https://quick-goldfinch-475.eu-west-1.convex.site.Before you start
The key stays on a server. API v1 sends no CORS headers, so a call from browser JavaScript fails, and a key in the browser is readable by anyone. If the tool runs in a browser (for example on an iPad), it posts the measurement to a small function of its own (a serverless function, a worker or a script on the office PC). That function holds the key and makes every call below.
Build and test against a practice account (Übungskonto). It has every Business feature, sample data and never emails a real recipient. Ask for one on the developer overview page (/developers, section „Das Übungskonto“). Switch to the real organization only by swapping the key.
The organization owner creates the key in Craftivo under Einstellungen → API & Webhooks → API-Schlüssel with the scope „Lesen & schreiben — z. B. Kunden anlegen“ (read_write). A drafts_only key cannot create customers or projects. The key acts with the rights of its creator: to send library positions with prices, the creator needs the right to see prices (the owner has it).
Every example below is a complete curl call. $CRAFTIVO_API_URL is the API host, $CRAFTIVO_API_KEY the key. Values in capitals such as $CUSTOMER_ID come from data.id of an earlier answer. Strings are UTF-8: send umlauts and ß as they are.
curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/me" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"What the tool keeps per measurement
The recipe expects this shape in the tool. Field names are the tool's own; only the requests below follow Craftivo's contract.
- A stable measurement id that never changes after recording, for example
118. EveryIdempotency-Keyis built from it. - The customer: name, phone, email, address, and the tool's own customer id if it has one.
- The address of the building where the work happens.
- Rooms, each with measurement rows: a short text („Wand Nord“) and a formula as typed on site (
4,20*2,50, a deduction with a minus:-0,90*2,10). - Per room the services by the business's own article number (
MAL-100walls,MAL-900mould treatment), optional items flagged as optional. - Photos and sketches as files.
One-time sync: put your services into the position library
Positions reach the quote by article number. Price, unit, title and calculation then come from Craftivo's position library, exactly as if the office had picked the position in Craftivo. The tool sends no prices for its own services.
Run this sync once when the tool is set up, and again when the business adds a service. Per article number: look it up (articleNumber is an exact, case-sensitive match); with no match create it; with one match use it; with more than one match stop and ask the office to clean up the library, because a quote with that number answers 409 ambiguous_article_number. Article numbers are not unique in Craftivo, so never create without looking first. The examples below use MAL-100 (walls, 12,50 € per m²) and MAL-900 (mould treatment, 24,00 € per m²).
Creating needs the documents right and, for unitPriceCents, the right to see sales prices. Prices are net, in cents. Later price changes happen in Craftivo or with PATCH /api/v1/positions/{positionId}.
curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/positions?articleNumber=MAL-100" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/positions" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: position-MAL-100" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"articleNumber": "MAL-100",
"title": "Wandflächen streichen, Dispersion weiß",
"category": "Malerarbeiten",
"unit": "m²",
"quantity": 1,
"unitPriceCents": 1250
}
JSON1. Find or create the customer
Look the customer up by the tool's own id (externalId), then by email. Only when both find nothing, create the customer and store the tool's id as externalId, so the next measurement finds it at once. When the email finds exactly one customer, keep its id in the tool; when it finds several, let the user pick. query searches names and city when the tool has neither id nor email.
PUT /api/v1/customers/external/{externalId} creates or updates in one call. Use it only when the tool is the master of customer data: it overwrites what the office corrected in Craftivo.
curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/customers?externalId=aufmass-kunde-118" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/customers?email=joerdis.weissenboeck%40example.com" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"# Keep data.id of the answer as $CUSTOMER_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/customers" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-kunde" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"customerType": "individual",
"salutation": "ms",
"firstName": "Jördis",
"lastName": "Weißenböck",
"email": "joerdis.weissenboeck@example.com",
"phone": "+49 251 123456",
"street": "Grevener Straße",
"houseNumber": "7a",
"postalCode": "48149",
"city": "Münster",
"externalId": "aufmass-kunde-118"
}
JSON2. Find or create the property (Objekt)
A property is the building the work happens in. Orders and projects link to it, so the office sees all work at that address. First list the customer's properties and compare street, house number and postal code. Without a match, search the whole organization by address: the building may already be there for a property management or another tenant. If it is, check its active parties with propertyId and customerId; attach the customer as a new party only when none comes back (a second hausverwaltung answers 409 conflict). Never create the building twice. Follow meta.cursor until meta.isDone is true on every list. Only without any match, create the property and attach the customer (owner for an owner, tenant for a tenant, hausverwaltung for a property management).
curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/properties?customerId=$CUSTOMER_ID" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/properties?query=Grevener%20Stra%C3%9Fe%207a%2048149" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"curl --request GET \
--url "$CRAFTIVO_API_URL/api/v1/parties?propertyId=$PROPERTY_ID&customerId=$CUSTOMER_ID" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY"# Keep data.id of the answer as $PROPERTY_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/properties" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-objekt" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"name": "Grevener Straße 7a, Wohnung 2. OG",
"street": "Grevener Straße",
"houseNumber": "7a",
"postalCode": "48149",
"city": "Münster",
"externalId": "aufmass-objekt-118"
}
JSONcurl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/parties" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-partei" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"propertyId": "$PROPERTY_ID",
"customerId": "$CUSTOMER_ID",
"role": "tenant"
}
JSON3. Upload files
Every photo or sketch takes two calls: upload the raw file, then attach the returned file id to the customer request or project (steps 4a–4c). Send the file itself as the body, no JSON and no multipart, with its MIME type in Content-Type and its name in fileName. A file id can be attached exactly once: an id already used answers 409 file_already_used on a project and 400 invalid_file on a customer request. Build the upload's Idempotency-Key from the target as well (aufmass-118-anfrage-upload-1, aufmass-118-projekt-upload-1), otherwise sending the same measurement first as a request and then as a project replays the used id. Unused uploads are deleted after 24 hours. At most 20 MB per file; images, PDF, Office files, CSV and text.
# Keep data.id of the answer as $FILE_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/files?fileName=Wohnzimmer%20S%C3%BCd.jpg" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-anfrage-upload-1" \
--header "Content-Type: image/jpeg" \
--data-binary @wohnzimmer-sued.jpg4a. Target: customer request with files
The request lands as a card in the first column of the customer request board, and the responsible member gets a notice. Put the measurement summary into description; Craftivo calculates nothing for a request, so the tool sums the rows itself or leaves the figures out. A request takes the address as text; it cannot link the property yet (see below). Optional: columnId from GET /api/v1/customer-request-columns picks another column.
The office later converts the request in Craftivo, or the tool does with POST /api/v1/customer-requests/{customerRequestId}/convert. Files and quotes move to the new project. A draft quote directly on the request: POST /api/v1/customer-requests/{customerRequestId}/offers, then fill it with PATCH /api/v1/quotes/{quoteId} and the positions of step 4c.
# Keep data.id of the answer as $CUSTOMER_REQUEST_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/customer-requests" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-anfrage" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"title": "Aufmaß 118: Wohnung Weißenböck streichen",
"description": "Wohnzimmer 19,11 m² Wand, Schlafzimmer 33,00 m² Wand. Fotos im Anhang.",
"customerId": "$CUSTOMER_ID",
"source": "manual",
"address": "Grevener Straße 7a, 48149 Münster"
}
JSONcurl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/customer-requests/$CUSTOMER_REQUEST_ID/files" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-anfrage-datei-1" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"fileId": "$FILE_ID"
}
JSON4b. Target: order (Auftrag)
An order is running work without a quote, for example a small repair agreed on site. It gets the next number of the order number range and appears on the order board. Attach photos to its file storage (Ablage); images appear as photos, other files as documents.
# Keep data.id of the answer as $PROJECT_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/projects" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-auftrag" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"type": "order",
"name": "Wohnung Weißenböck: Wände streichen",
"customerId": "$CUSTOMER_ID",
"propertyId": "$PROPERTY_ID",
"description": "Aus Aufmaß 118 vom 25.11.2026."
}
JSONcurl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/projects/$PROJECT_ID/files" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-auftrag-datei-1" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"fileId": "$FILE_ID"
}
JSON4c. Target: project with draft quote
Create the project, then one draft quote in it. Each room becomes a section (type: section) with its own key in id; its positions point to it with sectionId. A position from the library names its articleNumber. With measurements Craftivo calculates the quantity from the rows exactly as in the app: the sum of all rows, a row starting with a minus subtracts, a decimal comma works. A row's title starts a heading (the room) for the following rows.
isOptional: true makes an optional item (Eventualposition) that is printed but not counted in the totals. A position with parentPositionId becomes a sub-position (2.1 under 2) of the position directly above; a sub-position with isOptional: true is an alternative. A free position without library entry needs title, unit and unitPriceCents.
The quote stays a draft without a number. The office checks it in Craftivo and finalizes and sends it there. The answer contains the calculated quantity per position, subtotalCents per section and the totals; show them in the tool as the binding figures. Craftivo rounds each row half up to two decimals before it adds them up (3,90*2,55 gives 9,95), so a sum of unrounded rows can differ by 0,01. Then attach the photos to the project.
# Keep data.id of the answer as $PROJECT_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/projects" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-projekt" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"type": "project",
"name": "Wohnung Weißenböck renovieren",
"customerId": "$CUSTOMER_ID",
"propertyId": "$PROPERTY_ID"
}
JSON# Keep data.id of the answer as $QUOTE_ID
curl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/quotes" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-angebot" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"projectId": "$PROJECT_ID",
"title": "Malerarbeiten Wohnung Weißenböck",
"positions": [
{
"type": "section",
"id": "wohnzimmer",
"title": "Wohnzimmer"
},
{
"articleNumber": "MAL-100",
"id": "wohnzimmer-waende",
"sectionId": "wohnzimmer",
"measurements": [
{
"title": "Wohnzimmer",
"description": "Wand Nord",
"formula": "4,20*2,50"
},
{
"description": "Wand Süd",
"formula": "4,20*2,50"
},
{
"description": "Tür",
"formula": "-0,90*2,10"
}
]
},
{
"title": "Heizkörpernische spachteln",
"unit": "Stk",
"unitPriceCents": 3500,
"quantity": 1,
"sectionId": "wohnzimmer",
"parentPositionId": "wohnzimmer-waende"
},
{
"articleNumber": "MAL-900",
"sectionId": "wohnzimmer",
"quantity": 2,
"isOptional": true
},
{
"type": "section",
"id": "schlafzimmer",
"title": "Schlafzimmer"
},
{
"articleNumber": "MAL-100",
"sectionId": "schlafzimmer",
"measurements": [
{
"title": "Schlafzimmer",
"description": "Wände umlaufend",
"formula": "(3,50+3,10)*2*2,50"
}
]
}
]
}
JSONcurl --request POST \
--url "$CRAFTIVO_API_URL/api/v1/projects/$PROJECT_ID/files" \
--header "Authorization: Bearer $CRAFTIVO_API_KEY" \
--header "Idempotency-Key: aufmass-118-projekt-datei-1" \
--header "Content-Type: application/json" \
--data @- <<JSON
{
"fileId": "$FILE_ID"
}
JSON{
"data": {
"id": "p977…",
"number": null,
"finalizedAt": null,
"netAmountCents": 68638,
"positions": [
{
"type": "section",
"title": "Wohnzimmer",
"subtotalCents": 27388
},
{
"type": "position",
"articleNumber": "MAL-100",
"quantity": 19.11,
"unit": "m²",
"unitPriceCents": 1250,
"netAmountCents": 23888,
"measurements": [
{
"title": "Wohnzimmer",
"description": "Wand Nord",
"formula": "4,20*2,50",
"value": 10.5
},
{
"title": null,
"description": "Wand Süd",
"formula": "4,20*2,50",
"value": 10.5
},
{
"title": null,
"description": "Tür",
"formula": "-0,90*2,10",
"value": -1.89
}
]
},
"…"
]
}
}Rules a tool fails on
- One
Idempotency-Keyper call of a sending, built from the measurement id and the step (aufmass-118-angebot). A retry after a timeout sends the same key and gets the stored answer instead of a second customer or quote; keys are kept 30 days. Without the key, every retry ofPOST /api/v1/quotescreates another draft. The stored answer comes back even when the body changed: when the measurement is corrected after sending, keep the quote id in the tool and replace the rows withPATCH /api/v1/quotes/{quoteId}(positionsreplaces all rows) instead of sending again. - Send only fields from the schema. Quotes, properties, parties, positions and file links answer an unknown field with 400
invalid_bodyand save nothing. Customers, projects and customer requests still drop an unknown field silently (CI-8328), so compare the answer with what you sent. - Draft, not final. The tool creates draft quotes and never calls
finalizeorsend: a finalized quote gets its number and cannot be changed any more. The office finalizes in Craftivo. - Test in the practice account.
POST /api/v1/sandbox/resetrestores its sample data; the API keys stay. - No call from the browser (see „Before you start“).
- Amounts are integer cents, net. Formulas use a decimal comma or point; a formula Craftivo cannot calculate answers 400 and names the row.
- Errors are
{ "error": { "code", "message", "details" } }. Showmessageto the user; it names the field. On 429 waitRetry-Afterseconds, then send again with the same key.
What does not work yet
Measurement rows (CI-6364), sub-positions and alternatives (CI-6365) and files on a project or order (CI-6366) work as shown above. Still open:
- A customer request cannot link the property; send the address as text (CI-8329).
- Customers, projects and customer requests do not reject unknown fields yet (CI-8328).
- Files of a customer request cannot be listed through the API; keep the ids from the answers of step 4a (CI-7737).