API: Custom actions
Custom actions are a preconfigured set of changes that are applied to a work package.
Currently, this resource is a stub. The conditions and changes defined for the custom action are not yet present in the resource.
Actions
Link | Description | Condition |
---|---|---|
executeImmediately | Apply the action to a work package |
Linked Properties
Property | Description | Type | Constraints | Supported operations |
---|---|---|---|---|
self | This custom action | CustomAction | not null | READ |
Local Properties
Property | Description | Type | Constraints | Supported operations |
---|---|---|---|---|
id | Custom action id | Integer | x > 0 | READ |
name | The user selected name of the custom action | String | READ | |
description | A text describing the custom action | String | READ |
Methods
Get a custom action
Retrieves a custom action by id.
id
integer
required path
The id of the custom action to fetch
Example:42
200
OK
{
"_type": "CustomAction",
"name": "Change project and type",
"description": "Changes project and type in one go",
"_links": {
"executeImmediately": {
"href": "/api/v3/custom_actions/2/execute",
"title": "Execute Change project and type",
"method": "post"
},
"self": {
"href": "/api/v3/custom_actions/2",
"title": "Change project and type"
}
}
}
CustomActionModel
{
"type": "object",
"properties": {
"_type": {
"type": "string",
"enum": [
"CustomAction"
]
},
"name": {
"type": "string",
"description": "The name of the custom action"
},
"description": {
"type": "string",
"description": "The description for the custom action"
},
"_links": {
"type": "object",
"required": [
"self",
"executeImmediately"
],
"properties": {
"self": {
"allOf": [
{
"$ref": "#/components/schemas/Link"
},
{
"description": "This custom action\n\n**Resource**: CustomAction"
}
]
},
"executeImmediately": {
"allOf": [
{
"$ref": "#/components/schemas/Link"
},
{
"description": "Execute this custom action."
}
]
}
}
}
},
"examples": [
{
"_type": "CustomAction",
"name": "Change project and type",
"description": "Changes project and type in one go",
"_links": {
"executeImmediately": {
"href": "/api/v3/custom_actions/2/execute",
"title": "Execute Change project and type",
"method": "post"
},
"self": {
"href": "/api/v3/custom_actions/2",
"title": "Change project and type"
}
}
}
]
}
403
Returned if the client does not have sufficient permissions.
Required permission: edit work packages in any project
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
"message": "You are not authorized to access this resource."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
404
Returned if the custom action does not exist.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:NotFound",
"message": "The requested resource could not be found."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
Execute custom action
A POST to this end point executes the custom action on the work package provided in the payload. The altered work package will be returned. In order to avoid executing the custom action unbeknown to a change that has already taken place, the client has to provide the work package’s current lockVersion.
id
integer
required path
The id of the custom action to execute
Example:1
{
"example": {
"_links": {
"workPackage": {
"href": "/api/v3/work_packages/42"
}
},
"lockVersion": "3"
},
"properties": {
"_links": {
"properties": {
"workPackage": {
"properties": {
"href": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"lockVersion": {
"type": "string"
}
},
"type": "object"
}
200
OK
400
Occurs when the client did not send a valid JSON object in the request body.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:InvalidRequestBody",
"message": "The request body was not a single JSON object."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
403
Returned if the client does not have sufficient permissions.
Required permission: edit work packages - Additional permissions might be required based on the custom action.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:MissingPermission",
"message": "You are not authorized to access this resource."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
404
Returned if the custom action does not exist.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:NotFound",
"message": "The requested resource could not be found."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
406
409
Returned if the client provided an outdated lockVersion or no lockVersion at all.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:UpdateConflict",
"message": "Couldn't update the resource because of conflicting modifications."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
415
Occurs when the client sends an unsupported Content-Type header.
{
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:TypeNotSupported",
"message": "Expected CONTENT-TYPE to be (expected value) but got (actual value)."
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}
422
Returned if the custom action was not executed successfully e.g. when a constraint on a work package property was violated.
{
"_embedded": {
"details": {
"attribute": "lag"
}
},
"_type": "Error",
"errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation",
"message": "Lag must be a number greater than or equal to 0"
}
ErrorResponse
{
"type": "object",
"required": [
"_type",
"errorIdentifier",
"message"
],
"properties": {
"_embedded": {
"type": "object",
"properties": {
"details": {
"type": "object",
"properties": {
"attribute": {
"type": "string",
"example": "project"
}
}
}
}
},
"_type": {
"type": "string",
"enum": [
"Error"
]
},
"errorIdentifier": {
"type": "string",
"example": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation"
},
"message": {
"type": "string",
"example": "Project can't be blank."
}
}
}