Owner and owned objects

Objects in the REST API may be owned by other objects. For example, accounts-payable.bill-line is an owned object of accounts-payable.bill.

You can use the Model service to examine an owned object's relationship to the owning object, which is indicated by the isOwner: true property in the ref section of the response. For example, the response for the accounts-payable.bill-line object model contains the following:

Copy
Copied
"bill": {
           "apiObject": "accounts-payable/bill",
           "fields": {
               ...
           },
           "isOwner": true
        }

Operations on owned objects

You can invoke operations on an owned object directly or via its owner. For example, you can:

  • Create an owner and its owned objects at the same time.
  • Create an owner first, then create individual owned objects that designate their owner.
  • Update an owner by adding new owned objects and/or modifying any existing owned objects by key.
  • Update an owned object directly.
  • Delete an owned object via the owner.
  • Delete an owned object directly.

However, some owned objects can only be added/updated/deleted through the owning object. Use the Model service to find out what operations an object supports. Operations are listed under the httpMethods property.

Multiple records of owned objects specified in one request are processed in one atomic transaction when the request is made via the owning object.

Create an object and its owned objects

To create a new bill and its line items, provide the required fields for the bill object and include the bill lines array:

POST https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill

Copy
Copied
{
  "billNumber": "B-0073",
  "vendor": {
    "id": "1099 Int"
  },
  "postingDate": "2024-05-05",
  "dueDate": "2024-10-02",
  "createdDate": "2024-05-05",
  "lines": [
    {
      "account": {
        "id": "7120"
      },
      "txnAmount": 100,
      "location": {
        "id": "1"
      }
    },    {
      "account": {
        "id": "7120"
      },
      "txnAmount": 175,
      "location": {
        "id": "1"
      }
    }
  ]
}

Create an owned object directly

You can create owned objects directly. You must specify a reference to the owning object in the request. For example, the following request creates a bill line and specifies its owner (bill) by its key:

POST https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill-line

Copy
Copied
{
    "account": {
        "id": "7120"
    },
    "txnAmount": 100,
    "department": {
        "id": "1"
    },
    "location": {
        "id": "1"
    },
    "bill": {
        "key": "901"
    }
}

Update an object and its owned objects

If you specify a key for an owned object, you are updating that owned object. If you do not specify a key, you are adding a new owned object.

The following example updates an existing line of the bill (identified by the key) and adds a new line.

PATCH https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill/901

Copy
Copied
{
    "description": "Update line, add line",
    "lines": [
       {
          "key": "644",
          "txnAmount": "555.00"
       },
       {
          "txnAmount": "99.00",
          "accountLabel":
             {
                "id": "Accounting fees"
             }
       }
    ]
}

You can also delete a line from the owner as explained in Mixed operations.

Update an owned object directly

You can update owned objects directly. The following example shows how to change the transaction amount for an existing bill line:

PATCH https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill-line/644

Copy
Copied
{
  "txnAmount": "150"
}

You cannot update an owned object's reference to its owning object. That is, you can't change it to be owned by a different object.

Delete an owned object directly

Delete an owned object:

DELETE https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill-line/1092

Successful delete operations return 204 No Content (empty response).

Delete an owned object from the owner

To delete an owned object via the owner, see Mixed operations.

Mixed operations

You can use the PATCH operation on the owning object to add or delete owned objects, or to make changes to owned objects in one atomic request. The operation on the individual item record is determined as:

  • POST, when no key is specified in an item record
  • PATCH, when key is specified in an item record

To specify the DELETE operation:

  • Set a custom property ia:operation to delete .

For example, the following request deletes two lines, updates an existing line (identified by the key), and adds a new line:

PATCH https://api.intacct.com/ia/api/{version}/objects/accounts-payable/bill/901

Copy
Copied
 {
     "description": "UPDATED journal entry, deleted two lines",
     "lines": [
        {
            "ia::operation": "delete",
            "key": "7200"
        },
        {
            "ia::operation": "delete",
            "key": "7201"
        },
        {
            "key": "3455",
            "txnAmount": "560.00"
        },
        {
            "txnAmount": "109.00",
            "accountLabel":
               {
                  "id": "Service fee"
               }
        }
    ]
}