# Get Contact Audience

Reads one saved contact audience: its name, its conditions in the shape update-contact-audience takes, how many contacts match right now and which newsletters not yet sent address it. The count is every matching contact; a newsletter reaches only the subscribed ones among them. Reads only.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "audienceId": {
      "type": "integer",
      "description": "ID of the audience, from list-contact-audiences",
      "minimum": 1
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "User ID of the account; omit for the account of the access token",
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "audienceId"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "required": [
    "accountId",
    "audienceId",
    "name",
    "filter",
    "contactCount",
    "unsentNewsletters"
  ],
  "properties": {
    "accountId": {
      "type": "integer"
    },
    "audienceId": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "filter": {
      "type": "object",
      "properties": {
        "channel": {
          "type": "string",
          "enum": [
            "any",
            "email",
            "sms",
            "email-or-sms"
          ],
          "description": "Which subscriptions the email and sms conditions look at; \"any\" ignores both, \"email-or-sms\" matches a contact whose email or SMS part matches. With email-or-sms, statuses, bounces and dates go in one of email and sms only."
        },
        "email": {
          "type": "object",
          "description": "For channel email or email-or-sms; every condition left out matches every email subscription.",
          "properties": {
            "address": {
              "type": "object",
              "properties": {
                "operator": {
                  "type": "string",
                  "enum": [
                    "is",
                    "is-not",
                    "contains",
                    "does-not-contain",
                    "starts-with",
                    "does-not-start-with",
                    "ends-with",
                    "does-not-end-with",
                    "is-empty",
                    "is-not-empty"
                  ]
                },
                "value": {
                  "type": "string",
                  "maxLength": 250,
                  "description": "Not for is-empty and is-not-empty"
                }
              },
              "required": [
                "operator"
              ],
              "additionalProperties": false
            },
            "statuses": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "subscribed",
                  "unsubscribed",
                  "pending",
                  "pending-over-7-days",
                  "imported"
                ]
              },
              "uniqueItems": true,
              "description": "Any of them matches"
            },
            "bounces": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "not-bounced",
                  "soft",
                  "spam",
                  "hard"
                ]
              },
              "uniqueItems": true,
              "description": "Any of them matches"
            },
            "optInDate": {
              "type": "object",
              "properties": {
                "operator": {
                  "type": "string",
                  "enum": [
                    "on",
                    "not-on",
                    "before",
                    "after",
                    "between",
                    "not-between"
                  ]
                },
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD"
                },
                "until": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD, the last day of between and not-between"
                }
              },
              "required": [
                "operator",
                "date"
              ],
              "additionalProperties": false
            },
            "confirmationDate": {
              "type": "object",
              "properties": {
                "operator": {
                  "type": "string",
                  "enum": [
                    "on",
                    "not-on",
                    "before",
                    "after",
                    "between",
                    "not-between"
                  ]
                },
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD"
                },
                "until": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD, the last day of between and not-between"
                }
              },
              "required": [
                "operator",
                "date"
              ],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "sms": {
          "type": "object",
          "description": "For channel sms or email-or-sms; every condition left out matches every SMS subscription.",
          "properties": {
            "phoneNumber": {
              "type": "object",
              "properties": {
                "operator": {
                  "type": "string",
                  "enum": [
                    "is",
                    "is-not",
                    "contains",
                    "does-not-contain",
                    "starts-with",
                    "does-not-start-with",
                    "ends-with",
                    "does-not-end-with",
                    "is-empty",
                    "is-not-empty"
                  ]
                },
                "value": {
                  "type": "string",
                  "maxLength": 250,
                  "description": "Not for is-empty and is-not-empty"
                }
              },
              "required": [
                "operator"
              ],
              "additionalProperties": false
            },
            "statuses": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "subscribed",
                  "unsubscribed"
                ]
              },
              "uniqueItems": true,
              "description": "Any of them matches"
            },
            "bounces": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "not-bounced",
                  "soft",
                  "spam",
                  "hard"
                ]
              },
              "uniqueItems": true,
              "description": "Any of them matches"
            },
            "subscriptionDate": {
              "type": "object",
              "properties": {
                "operator": {
                  "type": "string",
                  "enum": [
                    "on",
                    "not-on",
                    "before",
                    "after",
                    "between",
                    "not-between"
                  ]
                },
                "date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD"
                },
                "until": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                  "description": "YYYY-MM-DD, the last day of between and not-between"
                }
              },
              "required": [
                "operator",
                "date"
              ],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "tags": {
          "type": "object",
          "description": "Tag conditions; include and exclude together at most 50 tags",
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "integer",
                "minimum": 1
              },
              "maxItems": 50,
              "description": "Tag IDs a contact must carry"
            },
            "includeMatch": {
              "type": "string",
              "enum": [
                "all",
                "any"
              ],
              "description": "Default all"
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "integer",
                "minimum": 1
              },
              "maxItems": 50,
              "description": "Tag IDs that keep a contact out"
            },
            "excludeMatch": {
              "type": "string",
              "enum": [
                "all",
                "any"
              ],
              "description": "Default any: one excluded tag keeps a contact out"
            }
          },
          "additionalProperties": false
        },
        "customFields": {
          "type": "array",
          "maxItems": 30,
          "description": "Conditions on custom field values, all of which must hold; one per field",
          "items": {
            "type": "object",
            "properties": {
              "fieldId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "description": "From search-custom-fields"
              },
              "operator": {
                "type": "string",
                "enum": [
                  "is-empty",
                  "is-not-empty",
                  "is",
                  "is-not",
                  "contains",
                  "does-not-contain",
                  "starts-with",
                  "does-not-start-with",
                  "ends-with",
                  "does-not-end-with",
                  "less-than",
                  "greater-than",
                  "before",
                  "after",
                  "between",
                  "not-between",
                  "on",
                  "not-on",
                  "at",
                  "not-at",
                  "checked"
                ],
                "description": "Which ones a field takes depends on its type"
              },
              "value": {
                "type": "string",
                "maxLength": 250,
                "description": "Date YYYY-MM-DD, time HH:MM, date and time YYYY-MM-DDTHH:MM, decimal 12.50, a dropdown its option value; not for is-empty and is-not-empty"
              },
              "values": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 250
                },
                "maxItems": 100,
                "description": "For checked: the option values that must be checked, exactly these"
              },
              "until": {
                "type": "string",
                "maxLength": 25,
                "description": "Upper end of between and not-between, same format as value"
              }
            },
            "required": [
              "fieldId",
              "operator"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "channel"
      ],
      "additionalProperties": false
    },
    "contactCount": {
      "type": [
        "integer",
        "null"
      ]
    },
    "unsentNewsletters": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "newsletterId",
          "name",
          "channel",
          "status"
        ],
        "properties": {
          "newsletterId": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "channel": {
            "type": "string",
            "enum": [
              "email",
              "sms"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "scheduled",
              "outgoing"
            ]
          }
        }
      }
    }
  }
}
```

