API method

createSale

Method allows to create order with specific details (in account selected currency).
Make sure you have all your account information set (contact, invoice data, etc.) on the website before submitting your first order!

GET
Usage URL
https://b2b.onesto-energy.pl/api/createSale.json?key=YOURAPIKEY

Query params

Put these in your URL, e.g. ?id=123.

  • lang string

    Language of result. ISO 2 Letter Language Codes

    Example

    en, pl, cs

  • test boolean 1 = true, 0 = false

    Enables a sandbox mode - no data will be written on the server.

POST data

Change the request to POST and send these fields as form-data.

  • fkshipmenttype integer
    required

    Shipment type internal identifier

  • fkpaymenttype integer
    required

    Payment type internal identifier

  • doc_type string
    required

    Which document should be assigned to sale. Available: "receipt" or "invoice"

  • shipment_diff_invoice boolean 1 = true, 0 = false

    Points whether shipping address is different from client (invoice) address. If set to yes, you have to fill "shipping" data This field is mandatory if you are using a drop-shipping client

  • currency string

    Currency symbol. If omitted - account currency will be picked

    Example

    Three letters format ie: PLN, EUR, USD.

  • is_assembling boolean 1 = true, 0 = false

    Points whether order is going to be modified or more products added

  • pickup_point string

    Unique ID of selected pickup point. Required only if fkshipmenttype points at the pickup point delivery type. This field replaces 6 old separate fields for each pickup point delivery shipment type. - For Poczta Polska - it's PNI, - For DHL - it's SAP

  • notice string

    Order's notice

  • products object[]
    required

    An array with requested products.

    Nested fields
    • id integer
      required

      Product internal ID

    • qty float
      required

      Product quantity you want to order

  • shipping object

    Array with shipping address - required only if "shipment_diff_invoice" = true

    Nested fields
    • receiver_name string
      required

      Receiver's full name / company name

    • postal_code string
      required

      Receiver's postal code

    • city string
      required

      Receiver's city

    • street string
      required

      Receiver's street

    • home_number string

      Receiver's building number

    • flat_number string

      Receiver's flat nummber

    • phone string
      required

      Receiver's phone number

    • email string
      required

      Receiver's email address

    • country string
      required

      Receiver's country - ISO2 code

      Example

      Two letters format ie: DE, PL, GB, US

  • own_label object

    Array with information about supplied own label. Required and processed only if you have selected a valid delivery method. Allows customer to send us their own delivery label for the package (as long as given provider is supported by us). Since 10th November 2022 it is possible to upload multiple files.
    To get a valid fkshipmenttype value for this option - please refer to either of those methods: getAvailableDeliveryOptions, getShipmentTypes.

    Nested fields
    • mode string
      required

      Allows us to identify which field should be use for file validation. Following values are allowed: pdf, url

    • provider string

      Delivery carrier for given label. Following values are allowed: dpd, dhl, inpost, pocztapolska, ups, orlen, emag, olzalogistic

    • items object[]

      Array with data for each given label

      Nested fields
      • url string

        URL address which points to your PDF label file. Make sure that given endpoint returns the correct PDF file and has 'Content-Type' header equal to 'application/pdf'. Required if mode = url

      • data string

        Base64 string with valid PDF inside. Required if mode = pdf

      • tracking_no string
        required

        Comma separated tracking numbers from given label. If only one label is passed then put here that one tracking number.

Response fields

Fields returned by this method.

  • ids integer[]

    Array with created sales IDs

  • messages object

    Generic success or failure message.
    Click here for more information

    Nested fields
    • success string[]

      List of success messages

    • danger string[]

      List of errors, blocks the operation

    • warning string[]

      List of warnings, does not block the operation

Input POST
fkshipmenttype=34&
fkpaymenttype=5&
notice=This is my notice&
doc_type=invoice&
inpost_box_name=WAW226M&
is_assembling=0&
shipment_diff_invoice=1&
products[0][id]=45356&
products[0][qty]=1&
products[1][id]=47990&
products[1][qty]=1&
shipping[receiver_name]=First and Last Name or Company Name&
shipping[postal_code]=23-456&
shipping[city]=Warsaw&
shipping[street]=Niepodleglosci&
shipping[home_number]=123&
shipping[flat_number]=&
shipping[phone]=+48 999-888-777&
shipping[email]=some-email@provider.com&
shipping[country]=PL&
invoice[vat_id]=DE8975305023&
invoice[regon]=&
invoice[name]=First and Last Name or Company Name&
invoice[firstname]=Test&
invoice[lastname]=Client&
invoice[postal_code]=12-345&
invoice[city]=Testing City&
invoice[street]=Test street&
invoice[home_number]=12&
invoice[flat_number]=34a&
invoice[phone]=+48 123-456-789&
invoice[country]=DE
Response JSON
Example URL: https://b2b.onesto-energy.pl/api/createSale.json?key=YOURAPIKEY&lang=en

{
    "messages": {
        "danger": [
            "You have unpaid overdue debts"
        ]
    }
}
Response XML
Example URL: https://b2b.onesto-energy.pl/api/createSale.xml?key=YOURAPIKEY&lang=en

<?xml version="1.0" encoding="utf-8"?>
<root>
	<messages>
		<danger>
			<item>You have unpaid overdue debts</item>
		</danger>
	</messages>
</root>