User's guide /

/

API

API

OBS2GO ERP allows integration and data exchange with third-party software products, such as other ERP systems, shell scripts, scheduled jobs, and other systems. It produces output in JSON format and uses the OBS ERP privileges module to control access. The latest version of the API allows the following operations:

In order to use the API, you need to have the CONSTRUCTOR module in your ERP instance. Every call to the API should include credentials in the following format: username and password.

How to generate an access token?

Open the control panel and go to the "API" section. Generate a new access token and store it somewhere securely. Additionally, you can restrict the API access to a specific IP address.

I. Insert records

Example: inserting a new record for a company called "TestCompany" in the "Companies" module:

    shell# curl -X POST -d "token={$TOKEN}" "https://acme.obs2go.com/api/companies/add"
    

Parameters:

  • 1.1. acme - domain of the ERP instance
  • 1.2. api - indicates the OBS2GO API
  • 1.3. companies - target module
  • 1.4. add - operation type used to insert data
  • 1.5. -d "token={$TOKEN}" - access token
  • 1.6. name - column name
  • 1.7. -X POST - method for issuing a POST request

Result - the result is a JSON string in the following format:

    {"ExitCode":0,"Error":"","Data":{"message":"Record 54 created","object":54}}
    

Description of the JSON keys:

  • ExitCode: 0 - operation successful; 1 - operation failed
  • Error - describes the error if the ExitCode is 1
  • Data.message - contains context-dependent data based on the operation type
  • Data.object - unique identifier of the newly created object

II. Obtain data

1. Simple filter:

Example - getting all invoices generated on 2016-02-04:

    curl -X POST -d 'token={$TOKEN}&filter__=[{"invoices_issue_date":"2016-02-04"}]' "https://acme.obs2go.com/api/invoices/all"
    

Description:

  • acme - domain of the ERP instance
  • api - OBS2GO API
  • invoices - target module
  • all - operation type to obtain information
  • filter__ - limits the results based on key-value pairs
  • invoices_issue_date - filter key-value pair

Result - JSON format:

    {"ExitCode":0,"Error":"","Data":{"data":[[10,"Open Business Solutions", "100.00", "20.00","120.00", "2016-3-5 0:0:0"],["id","company","base_amount", "tax_amount", "total_amount","due_date"]]}}
    

Description of JSON keys:

  • ExitCode: 0 - operation successful; 1 - operation failed
  • Error - describes the error if ExitCode is 1
  • Data.data - context-dependent data, including a list of invoices created on the specified date

To obtain invoice items related to a specific invoice:

    curl -d 'token={$TOKEN}&filter__=[{"invoice_items_record_id":10}]' "https://acme.obs2go.com/api/invoices/all"
    

JSON Response:

    {"ExitCode":0,"Error":"","Data":{"data":[[2,"test",null,"100.00","CNT","1.00",null,"100.00"],["id","name","description","price_per_unit", "unit","qty","discount","line_total"]]}}
    

2. Complex filters:

Example - getting a list of invoices based on their unique IDs:

    curl -d 'token={$TOKEN}&multiple_filter__=[{"invoices_id":[1,2,3,4,5,6,7,8,9,10,11]}]' "https://acme.obs2go.com/api/invoices/all"
    

Description:

  • multiple_filter__ - keyword used for complex filters with key-value pairs, where the value can be an array of elements
  • invoices_id - filter key-value pair

Result - JSON format:

    {"ExitCode":0,"Error":"","Data":{"data":[[]]}}
    

3. Searching records created between two dates:

    curl  -X POST  -d 'token={$TOKEN}&dates__=[{"start_time":"2011-05-02"},{"end_time":"2016-05-25"}]' "https://acme.obs2go.com/api/invoices/all"
    

To specify a custom date field:

    curl  -X POST  -d 'token={$TOKEN}&dates_map__=[{"check_in":{"start":"2018-06-01","end":"2018-08-15"}}]&dates__=[{"start_time":"2011-05-02"},{"end_time":"2016-05-25"}]' "https://acme.obs2go.com/api/invoices/all"
    

III. Update record

Example: Updating record 54 in the "Companies" module, setting the bank account to CB123456789, VAT number to 111222, and company name to "ACME INC":

    curl  -d 'token={$TOKEN}&vat_number=111222&name=ACME INC&bank_account=CB123456789&id=54' "https://acme.obs2go.com/api/companies/edit"
    

Result:

    {"ExitCode":0,"Error":"","Data":{"message":"Record 54 updated","object":54}}
    

IV. Delete record

Example: Deleting record 56 from the "Companies" module:

    curl -d "token={$TOKEN}" "https://acme.obs2go.com/api/companies/del_app_object/56"
    

Result:

    {"ExitCode":0,"Error":"","Data":{"message":"Record 56 deleted","object":56}}
    

V. Copy a specified record

Example: Copying company record 54:

    curl -d "token={$TOKEN}"  "https://acme.obs2go.com/api/companies/copy/54"
    

Result:

    {"ExitCode":0,"Error":"","Data":{"data":{"companies":[57]}}}
    

VI. Specific operations

Generating invoice, resetting sequence numbers, and more TBD.

VII. Initiate specific process

Example API call for initiating a specific process:

    http://d.obs.bg/api/quotations/process/1?mode=process&id_=1&module=quotations&process_name=status_id&step_id=7
    

For custom use cases, contact an OBS representative.

VIII. Other endpoints

1. Find a record by a key-value pair (e.g., find warehouse slip related to order ID 3433):

    curl -d "token={$TOKEN}" "https://acme.obs2go.com/api/warehouse_slips/get_record_by_key_val?key=order_id&value=3433"
    

Result:

    {
      "ExitCode": 0,
      "Error": "",
      "Data": {
        "shipping_terms": null,
        "status_id": 1,
        "tax_amount": null,
        .....
      }
    }