Attributes

The attributes object contains information about your contacts. As default every contact have attributes for email, first name and last name. You also have the ability to create custom attributes.


Renders: [application/json, text/html, application/xml]

Parses: [application/json, application/x-www-form-urlencoded, multipart/form-data]


Required fields

  • name

Optional fields

  • created

Readonly fields

  • url
  • code
  • usage_count
  • type

Example attribute

{
    "url": "https://api.getanewsletter.com/v3/attributes/city/",
    "name": "City",
    "code": "city",
    "usage_count": 2
}

GET /attributes/

Responds with a list of attributes, like usual we provide next, prev and count and the results

Possible url parameters are:

  • page: <int>

Example:

{
    "count": 46,
    "next": "https://api.getanewsletter.com/v3/attributes/?page=3,
    "previous": "https://api.getanewsletter.com/v3/attributes/?page=2,
    "results": [
        {
            "url": "https://api.getanewsletter.com/v3/attributes/city/",
            "name": "City",
            "code": "city",
            "usage_count": 324
        },
        ...
    ]
}

POST /attributes/

Creates a new attribute. The only required parameter is the name.

Example:

POST /attributes/
{
    "name": "City"
}

Response
{
    "url": "https://api.getanewsletter.com/v3/attributes/city/",
    "name": "City",
    "code": "city",
    "usage_count": 0
}
Location: https://api.getanewsletter.com/v3/attributes/city/

PUT /attributes/<code>/

Update or create an attribute, if an attribute doesn't exist it's created.

Keep in mind that the code cannot be changed after the creation of an attribute.

Status code is 200 if the attribute is updated and 201 if it's created

Example:

PUT /attributes/city/
{
    "name": "City"
}

Response
{
    "url": "https://api.getanewsletter.com/v3/attributes/city/",
    "name": "City",
    "code": "city",
    "usage_count": 0
}
201 Created
200 Updated

PATCH /attributes/<code>/

Patch is used for partial updates. Since attributes only has one updatable field it has the same effect as PUT.


DELETE /attributes/<code>/

Deletes the attribute.

Example:

DELETE /attributes/city/

Response
Status 204 No Content