This is an advanced feature. Only start using it if you are comfortable with our API.

Many-to-One Relationships

Since a message always has a conversation, they have a many-to-one relationship. This enables us to request all the messages and the conversation for each message.

curl "https://integration.getmateo.com/api/v1/message?select=id,conversation(subject)"
[
  {
    "id": 1,
    "conversation": {
      "subject": "Hello"
    }
  },
  {
    "id": 2,
    "conversation": {
      "subject": "Goodbye"
    }
  }
]

Note that the embedded conversation is returned as a JSON object because of the “to-one” end.

One-to-Many Relationships

The foreign key reference establishes the inverse one-to-many relationship. In this case, message returns as a JSON array because of the “to-many” end.

curl "https://integration.getmateo.com/api/v1/conversation?select=id,subject,messages(id)"
[
  {
    "id": 1,
    "subject": "Hello",
    "messages": [
      {
        "id": 1
      },
      {
        "id": 2
      }
    ]
  },
  {
    "id": 2,
    "subject": "Goodbye",
    "messages": [
      {
        "id": 3
      }
    ]
  }
]

Many-to-Many Relationships

In this example, a conversation has tags assigned via a conversation_tag relation. This is a many-to-many relationship.

curl "https://integration.getmateo.com/api/v1/conversation?select=id,subject,tag(name)"
[
  {
    "id": 1,
    "subject": "Hello",
    "tag": [
      {
        "name": "greeting"
      },
      {
        "name": "important"
      }
    ]
  },
  {
    "id": 2,
    "subject": "Goodbye",
    "tag": [
      {
        "name": "farewell"
      }
    ]
  }
]