Utilizing Meta Fields via API

Damon Self
Damon Self
  • Updated

Meta Fields 

This article will cover the various formats for creating resources with Meta Keys and Values via the RyderShip API. If you're looking for a general overview of Meta Fields, or how to create keys to use, you'll want to visit Meta Fields instead.

Since this article won't be listing any attributes other than meta_fields, If you have questions about which attributes are required during resource creation, check out our API documentation here.

General Request Overview

There are two primary methods of applying Meta Fields to RyderShip resources via the API:

    1. In the initial POST request body when creating a resource

    2. Via a PUT to that specific resource's /meta_fields endpoint

Additionally, assigning meta_keys on the Order Item and Shipnotice Item levels require different syntax if you want to assign them at the same time the Order/Shipnotice are created.

Assigning Meta Keys during the initial POST request:

# Assign meta keys + values on resource creation
# POST to /api/v2/#{resource}
# In this example, /api/v2/items
{
.. other JSON data you added..,
"meta_fields" : {
"fields" : {
"item_meta_key" : "value",
"item_color" : "value",
"ItemSizeDesc" : "value",
"itemProfitCenter" : "value",
"itemDivision" : "value"
}
}
}

Assigning Meta Keys via PUT to a specific resource:

# Update meta keys + values on existing resources
# PUT to /api/v2/#{resource}/#{id}/meta_fields
# In this example, /api/v2/orders/#{id}/meta_fields
{
"fields" : {
"orderBillingMethod" : "value",
"orderBillAcctNbr" : "value",
"orderCustomerId" : "value",
"orderCompanyId" : "value"
}
}

 

Assigning Meta Keys to Order Items/Shipnotice Items during initial POST request:

# POST to /api/v2/orders OR /api/v2/shipnotices, sub order_items for shipnotice_items
# You will need the item's originator's original_id to assign order item meta keys this way!
{
..other order JSON data you added..,
"order_items" : [
{
"item_id" : 1,
"originator_id" : "item_originator_original_id",
"quantity" : 1
}
],
"meta_fields" : {
"association_fields": {
"order_items": [
{
"originator_id": "item_originator_original_id",
"order_item_key" : "value"
}
]
}
}
}

 

Additionally, you can assign both Shipnotice and Shipnotice Item, and by extension Order and Order Item meta_fields at the same time like so:

{
..other shipnotice JSON data you added..,
"shipnotice_items" : [
{
"item_id" : 1,
"originator_id" : "item_originator_original_id",
"quantity" : 1
}
],
"meta_fields" : {
"fields" : {
"shipnotice_meta_key" : "value"
},
"association_fields": {
"shipnotice_items": [
{
"originator_id": "item_originator_original_id",
"shipnotice_item_key" : "value"
}
]
}
}
}

 

Related questions:

How do I create resources with Meta Keys and Values via the RyderShip API?

How do I assign Meta Keys during the initial POST request?

How do I assign Meta Keys via PUT to a specific resource?

How do I assign Meta Keys to Order Items/Shipnotice Items during initial POST request?

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request