Skip to content

Create a sales order or quote

Open .md

POST/v2/api/store/{team_slug}/v2/sales_order/new

v2Operation ID v2_public_order_create

Creates a new draft sales order or quote. The draft already has its order number (scoped_id, such as SO1001) but sends nothing to the customer; add jobs and lines, then publish it.

Set object_type to quote for a quote (or the older quote: true). Without either you get a sales order.

The new draft takes its defaults from the team and the customer: today's issue date, the customer's (or team's) pricing group, payment term and warehouse, the customer's primary brand profile, the team's starting status, and due and production dates from the team's settings.

The order number (scoped_id) is the team's next number unless you send your own, and publishing keeps it.

Typical flow: create the draft, add jobs (v2/sales_order/{hash_id}/job), add line items, then publish. The answer is the order: its id and unique_key, scoped_id (the number people see), name, object_type (sales_order or quote), internal_status (draft until published), status_id and status, the customer and addresses, dates, notes, is_rush, pricing settings and totals. The value of the order's lines is order_item_cart_total. invoiced_total, invoiced_order_item_subtotal, invoiced_shipment_subtotal, invoiced_tax_subtotal and invoiced_discount_subtotal count only what has been invoiced (0 until the order has an invoice). They are decimal pairs ({ "value": 850000, "dp": 4 } is 85.00; always read dp). paid_amount, calc_deposit_total and unallocated_amount are in thousandths (135000 is 135.00). deposit_total is a percentage ×1000 (50000 is 50%). calc_subtotal, calc_discount, calc_tax and calc_total are deprecated thousandths copies of the invoiced totals: they still return, but use the decimal pair fields instead.

Permission

Needs the create_order permission (the team owner always has it). Quotes use the same permission.

Business rules

  • The team must have a default pricing group: "This team must have a default pricing group configured before creating an order or quote."
  • object_type and quote, when both sent, must describe the same thing.
  • A customer synced from Shopify can't be used: "Shopify customer cannot be used for native order or quote creation."
  • Creating with is_external: true is refused for integrations.

Side effects

  • Creates a draft. No email, webhook or stock change happens until you publish.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team

Request body

application/json, required.

  • client_notestring | null

    The Client Note, printed on documents the customer receives.

  • The customer's id. Optional, but an order needs a customer before it can be published. An id that is not one of your customers is ignored.

  • customer_po_numberstring | null

    The customer's purchase order number.

  • quote for a quote; sales_order (the default) for a sales order.

    • One of: "sales_order", "quote"
  • quoteboolean

    Older way to ask for a quote. If you send both, they must agree.

  • scoped_idstring

    Your own order number. Leave it out to get the team's next number.

More examples (1)

A sales order for a customer

curl
curl -X POST 'https://secure.yoprint.com/v2/api/store/your-team/v2/sales_order/new' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -H 'Accept: application/json' \  -H 'X-Yoprint-Decimal-Format: exact-v1' \  -H 'Content-Type: application/json' \  -d '{    "customer_id": "63KcENAAsKuipY",    "customer_po_number": "PO-1188",    "object_type": "sales_order"  }'

Response

200Successful response.

  • dataobjectrequired

    A sales order or quote.

    Child fields (110)
    • idstringrequired

      The order's hash id: use it in every other call.

    • internal_statusstringrequired

      draft until published.

      • One of: "draft", "published"
    • object_typestringrequired
      • One of: "sales_order", "quote"
    • scoped_idstringrequired

      The order number people see, SO and at least four digits (quotes too). Not an id.

    • unique_keystringrequired

      The order's unique key (ord_…); accepted wherever {order_unique_key} is.

    • approval_statusstring | null

      requested, sent-to-customer, viewed-by-customer, need-changes or approved; null without approvals.

    • assigned_usersarray of objects

      The team members in the order's Assigned To list (always included).

      Fields of each item (5)
    • true when YoPrint keeps one invoice in step with the order.

    • DONOTMANAGE, NONE, MARKUP or MARGIN.

    • The MARKUP or MARGIN percentage. A decimal pair: the amount is value ÷ 10^dp ({ "value": 12500000, "dp": 6 } is 12.50). Kept with 6 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • auto_invoice_typestring | null

      How the automatic invoice is built. Always single_invoice today.

    • billing_addressobject | null

      An address, as the address operations return it.

      Child fields (8)
    • billing_address_idstring | null
    • calc_deposit_totalinteger | number | string | null

      The deposit amount, rounded to 2 decimal places: the percentage of order_item_cart_total, or of the invoiced total once every line is invoiced (or the invoiced total reaches the order's); 0 unless deposit_required. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • client_notestring | null

      The Client Note.

    • created_atstring (date-time) | null

      Created. ISO 8601 with offset, or null.

    • created_bystring | null

      Created By (a team member id).

    • creator_namestring | null
    • cust_due_datestring (date-time) | null

      Customer in-hands date. ISO 8601 with offset, or null.

    • customerobject | null

      Always present on order answers, lists included: the customer record, or null when the order has none. Get a sales order also nests the customer's contacts, addresses, brand profiles, tags, files and assigned users in it.

      Child fields (6)
    • The id of the contact on the order (the same contact as customer_contact_id), or null.

    • customer_contact_idstring | null
    • customer_idstring | null
    • customer_po_numberstring | null
    • customer_profile_idstring | null

      Brand profile.

    • deposit_amount_duedecimal pair

      Deposit still to pay (negative once overpaid). A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • deposit_duestring (date-time) | null

      Deposit due date. ISO 8601 with offset, or null.

    • deposit_totalinteger | number | string | null

      The deposit as a percentage of the order. A percentage ×1000: 8250 is 8.25%. With X-Yoprint-Decimal-Format: exact-v1, a value that isn't a whole number comes back as a string.

    • due_datestring (date-time) | null

      Production due. ISO 8601 with offset, or null.

    • external_idsarray of objects

      The order's links to records in other systems. An empty list when there are none.

    • external_typestring | null

      shopify for a Shopify order; null for YoPrint orders.

    • true for an order that was moved over from the old format.

    • full_amount_duestring (date-time) | null

      Full payment due date. ISO 8601 with offset, or null.

    • grouped_pdfarray of objects

      PDF links, grouped: Main (only for roles with view_order_finance), Job (not on Shopify orders), Shipment and the team's templates.

      Fields of each item (2)
    • true when the last sync with an integration failed.

    • true when the order has at least one invoice, so a zero invoiced total can be told apart from no invoice.

    • true when some line items are not on an invoice yet.

    • true when some line items are invoiced for more than the order has.

    • true when some line items are not on a shipment yet.

    • true when some line items are on shipments for more than the order has.

    • true when at least one of the order's invoices is in a valid state.

    • true when at least one of the order's shipments is in a valid state.

    • inventory_statusstring | null

      Stock status of the order's lines: not_committed, committed, partially_committed, not_applicable or pending.

    • invoice_lock_versioninteger | string | null

      Changes whenever the order's invoices change.

    • Discounts on the order's invoices; 0 until invoiced. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • The lines and shipping fees the order's invoices bill (the sum of their cart_item_subtotal); 0 until invoiced. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • The shipping fees in invoiced_order_item_subtotal; 0 until invoiced. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • Tax on the order's invoices; 0 until invoiced. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • invoiced_totaldecimal pair

      Total of the order's invoices. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • false for a Shopify order, whose client note comes from Shopify.

    • true for an order synced from an integration such as Shopify.

    • is_legacyboolean

      true for an order made in the old format.

    • is_rushboolean
    • issue_datestring (date-time) | null

      Issue date. ISO 8601 with offset, or null.

    • job_lock_versioninteger | string | null

      Changes whenever the order's jobs change.

    • last_payment_request_datestring (date-time) | null

      When a payment reminder was last emailed for the order. ISO 8601 with offset, or null.

    • lock_versioninteger | string | null

      Changes on every save.

    • modestring

      Older flag: create for a draft, view once published.

      • One of: "create", "view", "edit"
    • namestring | null
    • order_balance_duedecimal pair

      Invoiced total minus paid. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • The value of the order's lines: the order's own total before invoicing. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • order_item_lock_versioninteger | string | null

      Changes whenever the order's line items change.

    • Margin, in percent. A decimal pair: the amount is value ÷ 10^dp ({ "value": 1250, "dp": 2 } is 12.50). Kept with 2 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • Markup, in percent. A decimal pair: the amount is value ÷ 10^dp ({ "value": 1250, "dp": 2 } is 12.50). Kept with 2 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • order_profitdecimal pair

      Profit. A decimal pair: the amount is value ÷ 10^dp ({ "value": 1250, "dp": 2 } is 12.50). Kept with 2 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • paid_amountinteger | number | string | null

      Paid so far. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • payment_lock_versioninteger | string | null

      Changes whenever the order's payments change.

    • payment_term_idstring | null
    • pricing_group_idstring | null
    • pricing_strategystring | null

      job_separately, job_together or service_loc_together.

    • prod_notestring | null

      The production note.

    • producible_item_countnumber | integer | string | null

      Quantity to produce.

    • true when QuickBooks sync is off for this order.

    • quickbook_disable_sync_atstring (date-time) | null

      When the switch was last changed. ISO 8601 with offset, or null.

    • The team member who last changed the switch, or null.

    • The note given at the last change of the order's QuickBooks sync switch (off or back on), at most 500 characters, or null.

    • quickbook_last_error_syncstring (date-time) | null

      When a QuickBooks sync of the order last failed. ISO 8601 with offset, or null.

    • quickbook_last_success_syncstring (date-time) | null

      When QuickBooks last accepted the order. ISO 8601 with offset, or null.

    • quickbooks_holdobject | null

      Set when YoPrint holds back a QuickBooks payment covering this order: code is changed, deleted or rejected (the payment was changed or deleted in QuickBooks, or QuickBooks refused a change), and detail is already_deposited (the payment is in a QuickBooks bank deposit) or null. Null when nothing is held.

      Child fields (2)
      • codestring
        • One of: "changed", "deleted", "rejected"
      • detailstring | null
    • quoteboolean

      Older flag: true for a quote.

    • ship_due_datestring (date-time) | null

      Ship due date. ISO 8601 with offset, or null.

    • Whether those shipping fees are on an invoice. Null when there is nothing to bill.

    • The shipping fees you bill the customer on the order's shipments. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • Shipping cost incurred. A decimal pair: the amount is value ÷ 10^dp ({ "value": 125000, "dp": 4 } is 12.50). Kept with 4 decimal places; an amount never set can come as { "value": 0, "dp": 0 }. Read dp every time: it can differ between fields and records.

    • shipment_lock_versioninteger | string | null

      Changes whenever the order's shipments change.

    • shipping_addressobject | null

      An address, as the address operations return it.

    • shipping_address_idstring | null
    • shopify_last_error_syncstring (date-time) | null

      When a Shopify sync of the order last failed. Shopify orders only. ISO 8601 with offset, or null.

    • shopify_last_success_syncstring (date-time) | null

      When Shopify last accepted the order. Shopify orders only. ISO 8601 with offset, or null.

    • Shopify orders only: the Shopify event name behind the order's final state there. Null on YoPrint orders. The answer can also hold more shopify_* fields (shopify_admin_url, shopify_compliance_deletion, shopify_finance_notices, shopify_has_fulfillment_conflict, shopify_last_fulfillment_conflict_at): they are null or empty on YoPrint orders.

    • start_datestring (date-time) | null

      Production start. ISO 8601 with offset, or null.

    • statusobject | null

      The order's status (always included).

      Child fields (9)
      • colorstringrequired

        A hex color, such as #2196f3.

      • customer_labelstringrequired

        What customers see in the customer portal. When none is set: Pending for start, In Progress for in_progress and pre_production, Completed for end.

      • idstringrequired
      • labelstringrequired

        The status name people see.

      • positionintegerrequired

        Sort order within its list, lowest first.

      • rolestringrequired

        Which list the status belongs to: order, quote, job, shipment, purchase_order, pipeline or customer_message.

      • trashedbooleanrequired

        true for a deleted status.

      • typestringrequired

        start is the first status of its list and end the last; pre_production and in_progress are the ones in between.

        • One of: "start", "pre_production", "in_progress", "end"
      • The task preset, for pipeline statuses only; absent for other roles.

    • status_completion_datestring (date-time) | null

      When the order's status last moved to an end status. ISO 8601 with offset, or null.

    • status_idstring

      The order's status (from the team's sales order or quote statuses).

    • status_last_change_datestring (date-time) | null

      Last status change. ISO 8601 with offset, or null.

    • tagsarray of objects
      Fields of each item (3)
    • Quantity still to buy, as a decimal string with 8 decimal places ("24.00000000").

    • trashedboolean

      true when the order is deleted.

    • typestring

      Older name for object_type.

      • One of: "order", "quote"
    • unallocated_amountinteger | number | string | null

      Payments not yet allocated to an invoice. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • updated_atstring (date-time) | null

      Last changed. ISO 8601 with offset, or null.

    • versioninteger | string | null

      The order format version.

    • wallet_currency_isostring | null

      The order's currency code (USD and so on), or null on older orders without one.

    • warehouse_idstring | null
    • calc_discountinteger | number | string | nulldeprecated

      Deprecated: use invoiced_discount_subtotal, the same amount. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • calc_subtotalinteger | number | string | nulldeprecated

      Deprecated: use invoiced_order_item_subtotal, which already includes billed shipping. This older field adds invoiced_shipment_subtotal to it once more. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • calc_taxinteger | number | string | nulldeprecated

      Deprecated: use invoiced_tax_subtotal, the same amount. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • calc_totalinteger | number | string | nulldeprecated

      Deprecated: use invoiced_total, the same amount. Thousandths, an older encoding: 12500 is 12.50. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

  • statusintegerrequired
  • successbooleanrequired

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

    When
    The API key's role lacks create_order.
    Fix
    Ask the team owner for permission to create orders.
  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

  • 422The request was refused and changed nothing. validation_failed lists what to fix in error.fields; other codes name a business rule, explained in error.message. A few checks answer with only {"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer connect_timeout ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.

    When
    The team has no default pricing group, object_type and quote disagree, or the customer comes from Shopify.
    Fix
    Set a default pricing group in Settings, send matching values, or pick another customer.
    When
    is_external: true: "Cannot create external object from API."
    Fix
    Leave is_external out.

Notes

  • The answer's id is the order's id for every other call. Save it.
  • A new draft has no name; set one with Update.
  • Change the customer of a draft later with the change_customer action, not with Update.