Acumatica REST API Python Script Generator
Acumatica's contract-based REST API is the standard way to push items, customers and orders into the system. This generator writes a safe skeleton you can adapt, with login and logout handled properly.
Fill in
Python script
import requests
HOST = 'https://mycompany.acumatica.com'
VER = '22.200.001'
BASE = HOST + '/entity/Default/' + VER
s = requests.Session()
login = s.post(HOST + '/entity/auth/login', json={
'name': 'integration.user',
'password': 'CHANGE_ME',
'tenant': 'MyTenant',
'branch': 'MAIN',
})
login.raise_for_status()
try:
body = {
'InventoryID': {'value': 'BRKT-1001'},
'Description': {'value': 'Mounting bracket, 2 mm steel'},
}
r = s.put(BASE + '/StockItem', json=body)
r.raise_for_status()
print(r.status_code, r.json().get('InventoryID'))
finally:
s.post(HOST + '/entity/auth/logout')A PUT on the contract-based REST API inserts the record or updates it when the key already exists. Entity and field names depend on the endpoint version and on your customizations, so check them in the Web Service Endpoints screen. Keep credentials in a secrets store, never in the script, and always log out because open sessions count against your license. SalesOrder needs more required fields than shown.
Integration design review
Optional: have an expert review your Acumatica integration approach.
Optional. The tool and every export work without this. No spam.
How to use the script
Fill in your host, tenant, branch, endpoint version and the entity you want to write. Copy the script, replace the credential placeholders with values from a secrets store, and run it against a test tenant first. The script logs in with a cookie session, sends a PUT with the field values wrapped in value objects, and logs out in a finally block so a failure never leaves a session open.
How the API behaves
Each field in the JSON body is an object with a value property. A PUT acts as an upsert on the entity key. Related details such as order lines are sent as arrays of objects. The default endpoint and its version are listed on the Web Service Endpoints screen, and you can extend the contract with your own endpoint when you need custom fields.
- Use a test tenant before touching production
- One integration user per interface helps auditing
- Add retries with a delay for transient 5xx responses
Common mistakes
Frequent problems are forgetting to log out, which can exhaust concurrent API user limits, sending plain values instead of value objects, and using a version number that does not exist on the instance. Also remember that required fields vary with your item class and numbering setup, so a minimal body that works for one class can fail for another.
Frequently Asked Questions
Does a PUT create or update in Acumatica?
Both. If the key value does not exist the record is created, and if it does exist the supplied fields are updated. That makes it convenient for sync jobs, but you should still confirm required fields.
How do I find the endpoint version?
Open the Web Service Endpoints screen and look at the Default endpoint. The version is the number in the URL path, and it changes with major releases unless you pin your own endpoint.
Why must I log out?
Sessions count against the number of concurrent API users in your license. Forgetting to log out can lock other integrations out until the sessions expire.
Can I use OAuth instead of a cookie login?
Yes, Acumatica supports OAuth 2.0 flows with a connected application. This script uses the simple cookie login for clarity, and a production design should consider OAuth.
If you are building several of these integrations, we can help design and test them against your tenant. Ask about an integration review.
Related Tools
Acumatica OData Generic Inquiry URL Builder
Generate the OData URL for an Acumatica generic inquiry, with $filter, $select, $orderby and $top, ready for Excel, Power BI or a script.
Other ERPsAcumatica Screen ID Reference
Look up common Acumatica screen IDs and names for role setup, generic inquiries, import scenarios and support tickets.
ERP Migration & SelectionAcumatica Go-Live Cutover Checklist for Manufacturers
A cutover checklist covering data, inventory, open orders, security, integrations and rollback before and after an Acumatica go-live.
More Developer Tools tools
See all- Acumatica REST API URL Builder
- Acumatica Sales Order REST JSON Template
- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton