openapi: 3.1.0 info: title: Asana Allocations Rules API description: The Asana Allocations API allows users to manage and allocate resources within their Asana project management system. An allocation object represents how much of a resource (e.g. person, team) is dedicated to a specific work object (e.g. project, portfolio) over a specific period of time. The effort value can be a percentage or number of hours. version: '1.0' termsOfService: https://asana.com/terms contact: name: Asana Support url: https://asana.com/support license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0 servers: - url: https://app.asana.com/api/1.0 description: Main endpoint. security: - personalAccessToken: [] - oauth2: [] tags: - name: Rules description: '[Asana rules](https://help.asana.com/s/article/rules?language=en_US) allow you to automate common patterns and workflows in Asana. Rules comprise triggers that will automatically perform actions. For example, you can create a rule to automatically assign a task (action) when a due date is set (trigger). To support cross-application workflows, the API supports [incoming web requests](https://developers.asana.com/docs/incoming-web-requests) as a generic trigger to connect external applications to Asana through rules. This API allows users to set up workflows outside of Asana that can perform operations on data within Asana.' paths: /rule_triggers/{rule_trigger_gid}/run: parameters: - $ref: '#/components/parameters/rule_trigger_path_gid' post: summary: Asana Trigger a rule description: Trigger a rule which uses an ["incoming web request"](/docs/incoming-web-requests) trigger. tags: - Rules operationId: triggerRule requestBody: description: A dictionary of variables accessible from within the rule. required: true content: application/json: schema: type: object properties: data: $ref: '#/components/schemas/RuleTriggerRequest' responses: 200: description: Successfully triggered a rule. content: application/json: schema: type: object properties: data: $ref: '#/components/schemas/RuleTriggerResponse' 400: $ref: '#/components/responses/BadRequest' 401: $ref: '#/components/responses/Unauthorized' 402: $ref: '#/components/responses/PaymentRequired' 403: $ref: '#/components/responses/Forbidden' 404: $ref: '#/components/responses/NotFound' 500: $ref: '#/components/responses/InternalServerError' x-readme: code-samples: - language: node install: npm install asana code: "const Asana = require('asana');\n\nlet client = Asana.ApiClient.instance;\nlet token = client.authentications['token'];\ntoken.accessToken = '';\n\nlet rulesApiInstance = new Asana.RulesApi();\nlet body = {\"data\": {\"\": \"\", \"\": \"\",}}; // Object | A dictionary of variables accessible from within the rule.\nlet rule_trigger_gid = \"12345\"; // String | The ID of the incoming web request trigger. This value is a path parameter that is automatically generated for the API endpoint.\n\nrulesApiInstance.triggerRule(body, rule_trigger_gid).then((result) => {\n console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));\n}, (error) => {\n console.error(error.response.body);\n});" name: node-sdk-v3 - language: node install: npm install asana@1.0.5 code: "const asana = require('asana');\n\nconst client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN');\n\nclient.rules.triggerRule(ruleTriggerGid, {field: \"value\", field: \"value\", pretty: true})\n .then((result) => {\n console.log(result);\n });" name: node-sdk-v1 - language: python install: pip install asana code: "import asana\nfrom asana.rest import ApiException\nfrom pprint import pprint\n\nconfiguration = asana.Configuration()\nconfiguration.access_token = ''\napi_client = asana.ApiClient(configuration)\n\n# create an instance of the API class\nrules_api_instance = asana.RulesApi(api_client)\nbody = {\"data\": {\"\": \"\", \"\": \"\",}} # dict | A dictionary of variables accessible from within the rule.\nrule_trigger_gid = \"12345\" # str | The ID of the incoming web request trigger. This value is a path parameter that is automatically generated for the API endpoint.\n\n\ntry:\n # Trigger a rule\n api_response = rules_api_instance.trigger_rule(body, rule_trigger_gid)\n pprint(api_response)\nexcept ApiException as e:\n print(\"Exception when calling RulesApi->trigger_rule: %s\\n\" % e)" name: python-sdk-v5 - language: python install: pip install asana==3.2.3 code: 'import asana client = asana.Client.access_token(''PERSONAL_ACCESS_TOKEN'') result = client.rules.trigger_rule(rule_trigger_gid, {''field'': ''value'', ''field'': ''value''}, opt_pretty=True)' name: python-sdk-v3 components: responses: Forbidden: description: The authentication and request syntax was valid but the server is refusing to complete the request. This can happen if you try to read or write to objects or properties that the user does not have access to. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' PaymentRequired: description: The request was valid, but the queried object or object mutation specified in the request is above your current premium level. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' NotFound: description: Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' Unauthorized: description: A valid authentication token was not provided with the request, so the API could not associate a user with the request. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' BadRequest: description: This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' InternalServerError: description: There was a problem on Asana’s end. In the event of a server error the response body should contain an error phrase. These phrases can be used by Asana support to quickly look up the incident that caused the server error. Some errors are due to server load, and will not supply an error phrase. content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' schemas: Error: type: object properties: message: type: string readOnly: true description: Message providing more detail about the error that occurred, if available. example: 'project: Missing input' help: type: string readOnly: true description: Additional information directing developers to resources on how to address and fix the problem, if available. example: 'For more information on API status codes and how to handle them, read the docs on errors: https://asana.github.io/developer-docs/#errors''' phrase: type: string readOnly: true description: '*500 errors only*. A unique error phrase which can be used when contacting developer support to help identify the exact occurrence of the problem in Asana’s logs.' example: 6 sad squid snuggle softly ErrorResponse: description: 'Sadly, sometimes requests to the API are not successful. Failures can occur for a wide range of reasons. In all cases, the API should return an HTTP Status Code that indicates the nature of the failure, with a response body in JSON format containing additional information. In the event of a server error the response body will contain an error phrase. These phrases are automatically generated using the [node-asana-phrase library](https://github.com/Asana/node-asana-phrase) and can be used by Asana support to quickly look up the incident that caused the server error.' type: object properties: errors: type: array items: $ref: '#/components/schemas/Error' RuleTriggerResponse: type: object properties: message: description: Message providing more detail about the result type: string example: Successfully saved the payload and ran the rule RuleTriggerRequest: type: object properties: resource: description: The ID of the resource. For the duration of the beta, this resource is always a task, and this task must exist in the project in which the rule is created. type: string example: '12345' action_data: type: object additionalProperties: true description: The dynamic keys and values of the request. These fields are intended to be used in the action for the rule associated with this trigger. example: jira_ticket_name: Test jira_ticket_id: '123' required: - resource - action_data parameters: rule_trigger_path_gid: name: rule_trigger_gid in: path required: true description: The ID of the incoming web request trigger. This value is a path parameter that is automatically generated for the API endpoint. schema: type: string example: '12345' x-env-variable: rule securitySchemes: personalAccessToken: type: http description: A personal access token for the Asana API. scheme: bearer oauth2: type: oauth2 description: OAuth 2.0 authorization code flow. flows: authorizationCode: authorizationUrl: https://app.asana.com/-/oauth_authorize tokenUrl: https://app.asana.com/-/oauth_token scopes: default: Provides access to all endpoints documented in the API reference.