Targets

Targets are pointers to cloud-based applications and services such as Twitter and Twilio, as well as to HTTP and email addresses. You can use targets with triggers and automations to send a notification to the target when a ticket is created or updated. For a list of targets, see Notifying external targets.

To specify a target notification as an action for a trigger or automation, use the action's notification_target field. The field's value is an array of two strings specifying the numeric ID of the target and the message body. Example:

{
  "actions": [
    {"field": "notification_target", "value": ["32322", "Ticket {{ticket.id}} has been updated."]}
  ]
}

For more information, see Triggers or Automations.

JSON Format

Targets have the following common attributes:

Name Type Mandatory Comment
id integer Automatically assigned when created
title string yes A name for the target
type string A pre-defined target, such as "basecamp_target". See the additional attributes for the type that follow
active boolean Whether or not the target is activated
created_at date The time the target was created

"basecamp_target" has the following additional attributes:

Name Type Mandatory Comment
target_url string yes The URL of your Basecamp account, including protocol and path
username string The 37Signals username of the account you use to log in to Basecamp
password string The 37Signals password for the Basecamp account (only writable)
token string yes Get the API token from My info > Show your tokens > Token for feed readers or the Basecamp API in your Basecamp account
project_id string yes The ID of the project in Basecamp where updates should be pushed
resource string yes "todo" or "message"
message_id string Can be filled if it is a "todo" resource
todo_list_id string Can be filled if it is a "message" resource

"campfire_target" has the following additional attributes:

Name Type Mandatory Comment
subdomain string yes
ssl boolean
room string yes
token string yes
preserve_format boolean

"clickatell_target" has the following additional attributes:

Name Type Mandatory Comment
target_url string Read-only
method string Read-only
attribute string Read-only
username string yes
password string yes only writable
api_id string yes
to string yes
from string
us_small_business_account boolean

"email_target" has the following additional attributes:

Name Type Mandatory Comment
email string yes
subject string yes

"flowdock_target" has the following additional attributes:

Name Type Mandatory Comment
api_token string yes

"get_satisfaction_target" has the following additional attributes:

Name Type Mandatory Comment
email string yes
password string yes only writable
account_name string yes
target_url string

"jira_target" has the following additional attributes:

Name Type Mandatory Comment
target_url string yes
username string yes
password string yes only writable

"pivotal_target" has the following additional attributes:

Name Type Mandatory Comment
token string yes
project_id string yes
story_type string yes
story_title string yes
requested_by string
owner_by string
story_labels string

"twitter_target" has the following additional attributes:

Name Type Mandatory Comment
token string
secret string only writable

"url_target" has the following additional attributes:

Name Type Mandatory Comment
target_url string yes
method string "get"
attribute string yes
username string
password string only writable

"http_target" has the following additional attributes:

Name Type Mandatory Comment
target_url string yes
method string yes "get", "patch", "put", "post", or "delete"
username string
password string only writable
content_type string yes "application/json", "application/xml", or "application/x-www-form-urlencoded"

"yammer_target" has the following additional attributes:

Name Type Mandatory Comment
group_id string
token string
Example
{
  "id":         88335,
  "url":        "https://company.zendesk.com/api/v2/targets/88335.json",
  "created_at": "2012-02-20T22:55:29Z",
  "active":     false,
  "type":       "basecamp_target"
}

List Targets

GET /api/v2/targets.json

Allowed For:
  • Agents
Using curl
curl https://{subdomain}.zendesk.com/api/v2/targets.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "targets": [
    {
      "title":      "Fancy box",
      "type":       "basecamp_target"
      "active":     true
      "created_at": "2009-05-13T00:07:08Z",
      "id":         211
    },
    ...
  ]
}

Show Target

GET /api/v2/targets/{id}.json

Allowed For:
  • Agents
Using curl
curl https://{subdomain}.zendesk.com/api/v2/targets/{id}.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "target": {
    "title":      "Fancy box",
    "type":       "basecamp_target"
    "active":     true
    "created_at": "2009-05-13T00:07:08Z",
    "id":         211
  }
}

Create Target

POST /api/v2/targets.json

Allowed For
  • Admins
Using curl
curl https://{subdomain}.zendesk.com/api/v2/targets.json \
  -H "Content-Type: application/json" -X POST \
  -d '{"target": {"type": "email_target", "title": "Test Email Target", "email": "hello@example.com", "subject": "Test Target"}}' \
  -v -u {email_address}:{password}
Example Response
Status: 201 Created
Location: https://{subdomain}.zendesk.com/api/v2/targets/{id}.json

{
  "target": {
    "type":        "email_target",
    "title":       "Test Email Target",
    "active":      true,
    "email":       "hello@example.com",
    "subject":     "Test Target",
    "created_at":  "2009-05-13T00:07:08Z"
  }
}

Update Target

PUT /api/v2/targets/{id}.json

Allowed For
  • Admins
Using curl
curl https://{subdomain}.zendesk.com/api/v2/targets/{id}.json \
  -H "Content-Type: application/json" -X PUT \
  -d '{"target": {"email": "roger@example.com"}}' \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "target": {
    "type":        "email_target",
    "title":       "Test Email Target",
    "active":      true,
    "email":       "roger@example.com",
    "subject":     "Test Target",
    "created_at":  "2009-05-13T00:07:08Z"
  }
}

Delete Target

DELETE /api/v2/targets/{id}.json

Allowed For
  • Admins
Using curl
curl https://{subdomain}.zendesk.com/api/v2/targets/{id}.json \
  -H "Content-Type: application/json" -X DELETE \
  -v -u {email_address}:{password}
Example Response
Status: 204 No Content