Asana: Create a goal metric
Asana goals.createGoalMetric: arguments, response, policy and SDK examples.
← Goals operations · Get started
Operation asana.creategoalmetric
Provider route: POST /goals/{goal_gid}/setMetric. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/asana with npm, or alter-sdk-asana with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { AsanaIntegration } from "@alter-ai/asana";
async function execute(input: Parameters<AsanaIntegration["goals"]["createGoalMetric"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new AsanaIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.goals.createGoalMetric(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_asana import AsanaIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = AsanaIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.goals.create_goal_metric(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.goal_gid | string | Required within parent | |
query | Model | Optional | Expand Get a goal — request body — query |
body | object | Required within parent | |
body.data | Model | Optional | Expand Create a goal metric — request body — body data |
Referenced models: Create a goal metric — request body — body data, Get a goal — request body — query
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (allOf 1) | object | All variants apply | |
$ (allOf 1).data | Model | Optional | Expand Get a goal — response body — data data — Goal Response |
$ (allOf 2) | Model | All variants apply | Expand Get a goal — response body — data |
Referenced models: Get a goal — response body — data data — Goal Response, Get a goal — response body — data
Schemas
Section titled “Schemas”32 more schemas are linked from the tables above, on the schema pages.
Create a goal metric — request body — body data
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A generic Asana Resource, containing a globally unique identifier. |
gid | string | Optional | Globally unique identifier of the resource, as a string. Read only: true |
resource_type | string | Optional | The base type of this resource. Read only: true |
resource_subtype | string | Optional | The subtype of this resource. Different subtypes retain many of the same fields and behavior, but may render differently in Asana or represent resources with different semantic meaning. Read only: true One of: number |
precision | integer | Optional | *Conditional*. Only relevant for goal metrics of type `Number`. This field dictates the number of places after the decimal to round to, i.e. 0 is integer values, 1 rounds to the nearest tenth, and so on. Must be between 0 and 6, inclusive. For percentage format, this may be unintuitive, as a value of 0.25 has a precision of 0, while a value of 0.251 has a precision of 1. This is due to 0.25 being displayed as 25%. |
unit | string | Optional | A supported unit of measure for the goal metric, or none. One of: none, currency, percentage |
currency_code | JSON | Optional | |
currency_code (anyOf 1) | string | Alternative | ISO 4217 currency code to format this custom field. This will be null if the `unit` is not `currency`. |
currency_code (anyOf 2) | null | Alternative | |
initial_number_value | number | Optional | This number is the start value of a goal metric of type number. |
target_number_value | number | Optional | This number is the end value of a goal metric of type number. This number cannot equal `initial_number_value`. |
current_number_value | number | Optional | This number is the current value of a goal metric of type number. |
current_display_value | string | Optional | This string is the current value of a goal metric of type string. Read only: true |
progress_source | string | Optional | This field defines how the progress value of a goal metric is being calculated. A goal's progress can be provided manually by the user, calculated automatically from contributing subgoals, projects, or tasks, or managed by an integration with an external data source, such as Salesforce. One of: manual, subgoal_progress, project_task_completion, project_milestone_completion, task_completion, external |
is_custom_weight | boolean | Optional | *Conditional*. Only relevant if `metric.progress_source` is one of `subgoal_progress`, `project_task_completion`, `project_milestone_completion`, or `task_completion`. If true, we use the supporting object's custom weight to calculate the goal's progress. If false, we treat all supporting objects as equally weighted |
Get a goal — response body — data data — Goal Response
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (allOf 1) | Model | All variants apply | Expand Get a goal — response body — data data due on, gid, html notes, is workspace level, liked, name, notes, resource type, start on |
$ (allOf 2) | object | All variants apply | |
$ (allOf 2).likes | array | Optional | Array of likes for users who have liked this goal. Read only: true |
$ (allOf 2).likes[] | Model | Each item | Expand Get a story — response body — data / data / source: web, email, mobile, api, unknown, type: comment, system likes item |
$ (allOf 2).num_likes | JSON | Optional | |
$ (allOf 2).num_likes (anyOf 1) | integer | Alternative | The number of users who have liked this goal. Read only: true |
$ (allOf 2).num_likes (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
$ (allOf 2).team | JSON | Optional | |
$ (allOf 2).team (anyOf 1) | JSON | Alternative | |
$ (allOf 2).team (anyOf 1) (allOf 1) | Model | All variants apply | Expand Add a user to a team — response body — data data team — Team Compact |
$ (allOf 2).team (anyOf 1) (allOf 2) | object | All variants apply | *Conditional*. This property is only present when the `workspace` provided is an organization. |
$ (allOf 2).team (anyOf 2) | null | Alternative | |
$ (allOf 2).workspace | JSON | Optional | |
$ (allOf 2).workspace (allOf 1) | Model | All variants apply | Expand Update a workspace — request body — body data |
$ (allOf 2).workspace (allOf 2) | object | All variants apply | |
$ (allOf 2).followers | array | Optional | Array of users who are members of this goal. |
$ (allOf 2).followers[] | Model | Each item | Expand Get users in a team — response body — data data item |
$ (allOf 2).time_period | JSON | Optional | |
$ (allOf 2).time_period (anyOf 1) | JSON | Alternative | |
$ (allOf 2).time_period (anyOf 1) (allOf 1) | Model | All variants apply | Expand Get time periods — response body — data, next page data item |
$ (allOf 2).time_period (anyOf 1) (allOf 2) | object | All variants apply | |
$ (allOf 2).time_period (anyOf 2) | null | Alternative | |
$ (allOf 2).metric | JSON | Optional | |
$ (allOf 2).metric (anyOf 1) | JSON | Alternative | |
$ (allOf 2).metric (anyOf 1) (allOf 1) | Model | All variants apply | Expand Get a goal — response body — data / data / default_access_level: admin, editor, commenter, viewer, privacy setting: public to workspace, members only metric resource subtype: number, unit: none, currency, percentage resource subtype: number, unit: none, currency, percentage |
$ (allOf 2).metric (anyOf 1) (allOf 2) | object | All variants apply | |
$ (allOf 2).metric (anyOf 1) (allOf 2).can_manage | boolean | Optional | *Conditional*. Only relevant for `progress_source` of type `external`. This boolean indicates whether the requester has the ability to update the current value of this metric. This returns `true` if the external metric was created by the requester, `false` otherwise. Read only: true |
$ (allOf 2).metric (anyOf 2) | null | Alternative | |
$ (allOf 2).owner | JSON | Optional | |
$ (allOf 2).owner (anyOf 1) | JSON | Alternative | |
$ (allOf 2).owner (anyOf 1) (allOf 1) | Model | All variants apply | Expand Get users in a team — response body — data data item |
$ (allOf 2).owner (anyOf 1) (allOf 2) | object | All variants apply | |
$ (allOf 2).owner (anyOf 2) | null | Alternative | |
$ (allOf 2).current_status_update | JSON | Optional | |
$ (allOf 2).current_status_update (anyOf 1) | JSON | Alternative | |
$ (allOf 2).current_status_update (anyOf 1) (allOf 1) | Model | All variants apply | Expand Get status updates from an object — response body — data, next page data item |
$ (allOf 2).current_status_update (anyOf 1) (allOf 2) | JSON | All variants apply | The latest `status_update` posted to this goal. |
$ (allOf 2).current_status_update (anyOf 2) | null | Alternative | |
$ (allOf 2).status | JSON | Optional | |
$ (allOf 2).status (anyOf 1) | string | Alternative | The current status of this goal. When the goal is open, its status can be `green`, `yellow`, and `red` to reflect "On Track", "At Risk", and "Off Track", respectively. When the goal is closed, the value can be `missed`, `achieved`, `partial`, or `dropped`. *Note* you can only write to this property if `metric` is set. Read only: true |
$ (allOf 2).status (anyOf 2) | null | Alternative | |
$ (allOf 2).privacy_setting | string | Optional | The privacy setting of the goal. Known values: public_to_workspace, members_only |
$ (allOf 2).default_access_level | string | Optional | The default access level when inviting new members to the goal Known values: admin, editor, commenter, viewer |
$ (allOf 2).custom_fields | array | Optional | Array of custom field values applied directly to the goal itself. These represent the values set on the goal, not the fields available for items in the goal. |
$ (allOf 2).custom_fields[] | Model | Each item | Expand Get a membership — response body — data / data / access_level: admin, editor, user parent |
$ (allOf 2).custom_field_settings | array | Optional | Array of custom field definitions that are enabled for the goal. These represent which custom fields are available to be used on items within the goal, but do not include any values. |
$ (allOf 2).custom_field_settings[] | Model | Each item | Expand Add a custom field to a project — response body — data data — Custom Field Setting Response |
Referenced models: Get a goal — response body — data data due on, gid, html notes, is workspace level, liked, name, notes, resource type, start on, Get a story — response body — data / data / source: web, email, mobile, api, unknown, type: comment, system likes item, Get a membership — response body — data / data / access_level: admin, editor, user parent, Add a custom field to a project — response body — data data — Custom Field Setting Response, Get a goal — response body — data / data / default_access_level: admin, editor, commenter, viewer, privacy setting: public to workspace, members only metric resource subtype: number, unit: none, currency, percentage resource subtype: number, unit: none, currency, percentage, Get status updates from an object — response body — data, next page data item, Add a user to a team — response body — data data team — Team Compact, Get time periods — response body — data, next page data item, Get users in a team — response body — data data item, Update a workspace — request body — body data
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: asana.creategoalmetric. Catalog operation: asana:createGoalMetric. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.