Docs
/
/

Goals mAPI reference

Complete reference documentation for the Goals resource.

Goals

#

A goal defines an event condition that Knock tracks and attributes to the workflows, guides, and broadcasts that drove it.

You can retrieve, update, create, validate, clone, and archive goals, as well as list all goals in a given environment. Goals are identified by their unique goal key.

List goals

#

Returns a paginated list of goals for the given environment.

Endpoint

GET/v1/goals

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

after
string

The cursor to fetch entries after.

before
string

The cursor to fetch entries before.

limit
integer

The number of entries to fetch per-page.

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

Returns

PaginatedGoalResponse

A paginated list of Goal. Contains a list of entries and page information.

entries

A list of entries.

conditionRequired

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)
Required

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string
Required

The slug of the environment in which the goal exists. (read-only).

key
string
Required

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string
Required

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string
Required

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)
Required

The timestamp of when the goal was last updated. (read-only).

page_info

The information about a paginated result.

after
string

The cursor to fetch entries after. Will only be present if there are more entries to fetch.

before
string

The cursor to fetch entries before. Will only be present if there are more entries to fetch before the current page.

page_size
integer

The number of entries to fetch per-page.

Archive a goal

#

Archives a given goal across all environments. Refuses if any workflow, guide, or broadcast is attached to the goal.

Endpoint

DELETE/v1/goals/{goal_key}

Path parameters

goal_key
string

The key of the goal to archive.

Query parameters

environment
string

The environment slug.

Returns

ArchiveGoalResponse

The response from archiving a goal.

result
string

The result of the archive operation.

Get a goal

#

Retrieve a goal by its key in a given environment.

Endpoint

GET/v1/goals/{goal_key}

Path parameters

goal_key
string

The key of the goal to retrieve.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

Returns

A goal defines an event condition that is tracked and attributed to messaging resources.

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the goal exists. (read-only).

key
string

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)

The timestamp of when the goal was last updated. (read-only).

Upsert a goal

#

Updates a goal of a given key, or creates a new one if it does not yet exist. The goal is published immediately; this endpoint does not accept a commit parameter.

Endpoint

PUT/v1/goals/{goal_key}

Path parameters

goal_key
string

The key of the goal to upsert.

Query parameters

environment
string

The environment slug.

annotate
boolean

Whether to annotate the resource. Only used in the Knock CLI.

Request body

A goal payload for upsert or validate.

conditionRequired

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

description
string

An optional description for the goal. Maximum of 280 characters allowed.

name
string
Required

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

Returns

WrappedGoalResponse

Wraps the Goal response under the goal key.

goal

A goal defines an event condition that is tracked and attributed to messaging resources.

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the goal exists. (read-only).

key
string

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)

The timestamp of when the goal was last updated. (read-only).

Validate a goal

#

Validates a goal payload without persisting it.

Endpoint

PUT/v1/goals/{goal_key}/validate

Path parameters

goal_key
string

The key of the goal to validate.

Query parameters

environment
string

The environment slug.

branch
string

The slug of a branch to use. This option can only be used when environment is "development".

Request body

A goal payload for upsert or validate.

conditionRequired

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

description
string

An optional description for the goal. Maximum of 280 characters allowed.

name
string
Required

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

Returns

WrappedGoalResponse

Wraps the Goal response under the goal key.

goal

A goal defines an event condition that is tracked and attributed to messaging resources.

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the goal exists. (read-only).

key
string

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)

The timestamp of when the goal was last updated. (read-only).

Clone a goal

#

Clones a goal into a destination environment.

Endpoint

POST/v1/goals/{goal_key}/clone

Path parameters

goal_key
string

The key of the source goal to clone.

Query parameters

environment
string

The environment slug.

Request body

clone
CloneGoalRequest

The destination key, name, and environment for the cloned goal.

environment
string
Required

The destination environment slug.

key
string
Required

The key for the cloned goal.

name
string
Required

The name for the cloned goal.

Returns

WrappedGoalResponse

Wraps the Goal response under the goal key.

goal

A goal defines an event condition that is tracked and attributed to messaging resources.

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types
Required

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the goal exists. (read-only).

key
string

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)

The timestamp of when the goal was last updated. (read-only).

GoalCondition

#

A goal condition consisting of a polymorphic event and optional match conditions.

Attributes

event
3 possible types

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

GoalRequest

#

A goal payload for upsert or validate.

Attributes

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

description
string

An optional description for the goal. Maximum of 280 characters allowed.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

Goal

#

A goal defines an event condition that is tracked and attributed to messaging resources.

Attributes

condition

A goal condition consisting of a polymorphic event and optional match conditions.

event
3 possible types

The event to track. Supports recipient, integration_source, and audience event types.

match_conditions

A list of condition groups. Required for recipient events; each group uses an operator (and/or) with nested conditions.

created_at
string(date-time)

The timestamp of when the goal was created. (read-only).

description
string

An optional description for the goal. Maximum of 280 characters allowed.

environment
string

The slug of the environment in which the goal exists. (read-only).

key
string

The unique key string for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

name
string

A name for the goal. Must be at minimum 1 character and at maximum 255 characters in length.

sha
string

The SHA hash of the goal data. (read-only).

updated_at
string(date-time)

The timestamp of when the goal was last updated. (read-only).

New chat