nodejs

Choose Language

Metadata Calls

/metadata/list.json

Get the list of custom metadata fields indexed for the account.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); mandrill_client.metadata.list({}, function(result) { console.log(result); /* [{ "name": "group_id", "state": "active", "view_template": "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>" }] */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Invalid_Key - Invalid API key });
Parameters
No parameters
Return Value
array the custom metadata fields for the account
return[] struct the individual custom metadata field info
name string the unique identifier of the metadata field to update
state string the current state of the metadata field, one of "active", "delete", or "index"
view_template string Mustache template to control how the metadata is rendered in your activity log
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/metadata/add.json

Add a new custom metadata field to be indexed for the account.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var name = "group_id"; var view_template = "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>"; mandrill_client.metadata.add({"name": name, "view_template": view_template}, function(result) { console.log(result); /* { "name": "group_id", "state": "active", "view_template": "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>" } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Metadata_FieldLimit - Custom metadata field limit reached. });
Parameters
name* string a unique identifier for the metadata field
Validation: required, maxlength(64)
view_template string optional Mustache template to control how the metadata is rendered in your activity log
Validation: maxlength(1024)
Return Value
struct the information saved about the new metadata field
name string the unique identifier of the metadata field to update
state string the current state of the metadata field, one of "active", "delete", or "index"
view_template string Mustache template to control how the metadata is rendered in your activity log
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
Metadata_FieldLimit Custom metadata field limit reached.
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/metadata/update.json

Update an existing custom metadata field.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var name = "group_id"; var view_template = "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>"; mandrill_client.metadata.update({"name": name, "view_template": view_template}, function(result) { console.log(result); /* { "name": "group_id", "state": "active", "view_template": "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>" } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Unknown_MetadataField - No custom metadata field exists with the name 'group_id' });
Parameters
name* string the unique identifier of the metadata field to update
Validation: required
view_template* string optional Mustache template to control how the metadata is rendered in your activity log
Validation: maxlength(1024)
Return Value
struct the information for the updated metadata field
name string the unique identifier of the metadata field to update
state string the current state of the metadata field, one of "active", "delete", or "index"
view_template string Mustache template to control how the metadata is rendered in your activity log
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
Unknown_MetadataField The provided metadata field name does not exist.
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.

/metadata/delete.json

Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.

Example Call

mandrill_client = new mandrill.Mandrill('YOUR_API_KEY'); var name = "group_id"; mandrill_client.metadata.delete({"name": name}, function(result) { console.log(result); /* { "name": "group_id", "state": "active", "view_template": "<a href=\"http://yourapplication.com/user/{{value}}\">{{value}}</a>" } */ }, function(e) { // Mandrill returns the error as an object with name and message keys console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message); // A mandrill error occurred: Unknown_MetadataField - No custom metadata field exists with the name 'group_id' });
Parameters
name* string the unique identifier of the metadata field to update
Validation: required
Return Value
struct the information for the deleted metadata field
name string the unique identifier of the metadata field to update
state string the current state of the metadata field, one of "active", "delete", or "index"
view_template string Mustache template to control how the metadata is rendered in your activity log
Errors
Invalid_Key The provided API key is not a valid Mandrill API key
Unknown_MetadataField The provided metadata field name does not exist.
ValidationError The parameters passed to the API call are invalid or not provided when required
GeneralError An unexpected error occurred processing the request. Mandrill developers will be notified.