Core Resources
Metafields
We now have metafields endpoint on our API!
Metafields feature allows you to add additional information to other resources. They can be used for adding custom fields to objects, and are useful for storing specialized information.
Metafields feature allows you to add additional information to other resources. They can be used for adding custom fields to objects, and are useful for storing specialized information.
#The metafield object
Metafields feature allows you to add additional information to other resources. They can be used for adding custom fields to objects, and are useful for storing specialized information.
Attributes
- idintegerUnique numeric identifier for the metafield.
- created_atdatetimeThe date and time when the metafield was created.
- descriptionstringDescription of the metafield.
- keystringThe name of the metafield.
- namespacestringA category or container that differentiates your metadata from other metafields.
- owner_idstringUnique numeric identifier of the owner resource.
- owner_resourcestringThe owner of the resource can be one of the following values:
address,store,customer,subscription,order,charge. There may be more objects added in the future. - updated_atdatetimeThe date and time when the metafield was last updated.
- valuestringThe content of the metafield.
- value_typestringThe type of the value parameter.
{
"metafield": {
"id": 33,
"created_at": "2018-11-07T14:00:10",
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_id": 18301938,
"owner_resource": "customer",
"updated_at": "2018-11-07T14:00:10",
"value": "3103103101",
"value_type": "integer"
}
}#Create a metafield
POST/metafields
Creates metafield for specific object.
Note:There is a limit of 50 metafields per owner_id.
Note:There is a limit of 50 metafields per owner_id.
Body parameters
- descriptionstringDescription of the metafield.
- The name of the metafield.
- A category or container that differentiates your metadata from other metafields.
- Unique numeric identifier of the owner resource.
- The owner of the resource can be one of the following values:
address,store,customer,subscription,order,charge. There may be more objects added in the future. - The content of the metafield.
- The type of the value parameter. Valid values are
"string","json_string"and"integer"
curl -X POST 'https://api.rechargeapps.com/metafields' \
-H 'Content-Type: application/json' \
-H 'X-Recharge-Access-Token: your_api_token' \
-d '{
"metafield": {
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_resource": "customer",
"owner_id": 18301938,
"value_type": "integer",
"value": "3103103101"
}
}'{
"metafield": {
"id": 33,
"created_at": "2018-11-07T14:00:10",
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_id": 18301938,
"owner_resource": "customer",
"updated_at": "2018-11-07T14:00:10",
"value": "3103103101",
"value_type": "integer"
}
}#Retrieve a metafield
GET/metafields/{id}
Retrieves a single metafield based on specified id.
## HTTP request examples
In addition to that, you can retrieve them by “subscription_id” by using:
## HTTP request examples
GET /metafields/<metafield_id> In addition to that, you can retrieve them by “subscription_id” by using:
GET /metafields?owner_resource=subscription&owner_id=<subscription_id>curl 'https://api.rechargeapps.com/metafields/33' \
-H 'X-Recharge-Access-Token: your_api_token'{
"metafield": {
"id": 33,
"created_at": "2018-11-07T14:00:10",
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_id": 18301938,
"owner_resource": "customer",
"updated_at": "2018-11-07T14:00:10",
"value": "3103103101",
"value_type": "integer"
}
}#Update a metafield
PUT/metafields/{id}
Updates metafield based on specified owner resource.
Body parameters
- descriptionstringDescription of the metafield.
- owner_idstringUnique numeric identifier of the resource.
- owner_resourcestringThe owner of the resource can be one of the following values:
address,store,customer,subscription,order,charge. There may be more objects added in the future. - valuestringThe content of the metafield.
- value_typestringThe type of the value parameter. Valid values are
"string","json_string"and"integer"
curl -X PUT 'https://api.rechargeapps.com/metafields/33' \
-H 'Content-Type: application/json' \
-H 'X-Recharge-Access-Token: your_api_token' \
-d '{
"metafield": {
"description": "phone_number_of_customer",
"owner_id": 18293088,
"owner_resource": "customer",
"value": "0333103133",
"value_type": "integer"
}
}'{
"metafield": {
"id": 33,
"created_at": "2018-11-07T14:00:10",
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_id": 18301938,
"owner_resource": "customer",
"updated_at": "2018-11-07T14:00:10",
"value": "3103103101",
"value_type": "integer"
}
}curl -X DELETE 'https://api.rechargeapps.com/metafields/6' \
-H 'X-Recharge-Access-Token: your_api_token'{}#List metafields
GET/metafields
Retrieves a list of metafields.
## HTTP request examples
When getting metafields, you must specify owner_resource in the URL. It can be
You can list metafields that are created for all subscription objects using:
Metafields are filterable by any of the following parameters:
## HTTP request examples
GET /metafields?owner_resource=<owner_resource> GET /metafields?owner_resource=subscription&owner_id=<subscription_id> GET /metafields?owner_resource=customer&owner_id=<customer_id> GET /metafields?owner_resource=store&owner_id=<store_id> When getting metafields, you must specify owner_resource in the URL. It can be
address, store, customer, subscription, order, charge You can list metafields that are created for all subscription objects using:
GET /metafields?owner_resource=subscription - owner_id in the response will be the ID of the subscription. Metafields are filterable by any of the following parameters:
Query parameters
- limitstringAmount of results.
(default:50) (maximum: 250). - namespacestringA category or container that differentiates your metadata from other metafields.
- owner_idstringUnique numeric identifier of the owner resource.
- owner_resourcestringThe owner of the resource can be one of the following values:
address,store,customer,subscription,order,charge. There may be more objects added in the future. - Page to show.Page-based pagination has been deprecated but still available to use for pages up to a 100. If you need data past this point, use cursor pagination.
curl 'https://api.rechargeapps.com/metafields?owner_resource=store&limit=3' \
-H 'X-Recharge-Access-Token: your_api_token'{
"metafields": [
{
"id": 33,
"created_at": "2018-11-07T14:00:10",
"description": "customer_phone_number",
"key": "phone_number",
"namespace": "personal_info",
"owner_id": 18301938,
"owner_resource": "customer",
"updated_at": "2018-11-07T14:00:10",
"value": "3103103101",
"value_type": "integer"
},
{
"id": 15,
"created_at": "2018-11-05T12:59:30",
"description": "desc lorem ipsum",
"key": "marjan",
"namespace": "nmsp2c",
"owner_id": 17868054,
"owner_resource": "customer",
"updated_at": "2018-11-05T15:48:42",
"value": "5",
"value_type": "integer"
},
{
"id": 9,
"created_at": "2018-11-05T12:47:27",
"description": "desc lorem ipsum",
"key": "marjan",
"namespace": "nmspc",
"owner_id": 17868054,
"owner_resource": "customer",
"updated_at": "2018-11-05T12:47:27",
"value": "5",
"value_type": "integer"
}
]
}#Count metafields
GET/metafields/count
Retrieves a number of metafields for some specific query parameter.
## HTTP request examples
When getting metafields, you must specify owner_resource in the URL. It can be
## HTTP request examples
GET /metafields/count?owner_resource=<owner_resource> When getting metafields, you must specify owner_resource in the URL. It can be
address, store, customer, subscription, order, chargeQuery parameters
- namespacestringA category or container that differentiates your metadata from other metafields.
- owner_idstringUnique numeric identifier of the owner resource.
- owner_resourcestringThe owner of the resource can be one of the following values:
address,store,customer,subscription,order,charge. There may be more objects added in the future.
Response attributes
- countinteger
curl 'https://api.rechargeapps.com/metafields/count?owner_resource=store' \
-H 'X-Recharge-Access-Token: your_api_token'{
"count": 3
}