Create Action

Create Actions Endpoint

POST {baseUrl}/openapi/api/v1/actions


The Create Actions API enables partners to bulk-create actions by submitting a structured payload.

The API:

  • Validates the input

  • Maps it to the legacy API format

  • Processes the request

  • Returns a detailed response


Request Requirements

  1. Authorization:

    • Include a valid JWT token in the Authorization header.

    • Tokens are validated via Keycloak before processing.

  2. Validation:

    • The service validates all payloads in the request before forwarding them to the legacy API.

    • If any payload fails validation, the entire request is rejected, and no calls to the legacy API are made.

    • Fields are validated for existence. So, if some of the mandatory fields do not exists an error will be thrown. In the first example, the input payload can be seen as what is required(validated) and what is optional(not validated)

  3. Bulk Operation:

    • Supports bulk creation of actions in a single request.

    • Legacy API may return mixed results (successes and failures) for individual payloads.

  4. Response

  • 201 - Success All actions are successfully created.

  • 207 - Partial Success At least one action failed. This can include:

    • Response with successfully created actions and errors

    • Completely failed response in combination with other successful or partially successful response

  • 400 - Failure Validation of the payload failed, and no actions were processed.

Examples

Example input of complete(non-partial) success 201:

{
  "data": [
    {
      "partner_ids": [
        "6042dbca-93a4-418e-b625-b7da58eaf6d4",
        "21d6955f-244e-439a-a432-a45d45ab8b34"
      ],
      "title": { #Required
        "en": "Leave Approval", #Required
        "fr": "Approbation de congé" #Required
      },
      "subtitle": { #Optional
        "en": "Leave request for approval",
        "fr": "Demande de congé pour approbation"
      },
      "details": { #Required
        "en": "Please approve the leave request via the external tool.",
        "fr": "Veuillez approuver la demande de congé via l'outil externe."
      },
      "status": "active", #Optional validated 
      "effective_date": "2024-03-15 00:00:00",
      "due_date": "2024-01-19 06:51:15",
      "expires_at": "2024-03-18 00:09:30",
      "author_id": "21d6955f-244e-439a-a432-a45d45ab8b34",
      "client_info": {
        "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
        "provider_name": "CSOD",
        "company_name": "Sfam",
        "module_name": "EPM_PERF_REVIEW"
      },
      "redirect_url": "https://lucca.fr/action/validate?id=1234",
      "category_action": "link",
      "type_action": "link",
      "priority": "high",
      "action_group": "Sales Department",
      "expiration_blocks": {
        "due_soon": "2024-01-25 00:00:00",
        "due_later": "2024-12-31 00:00:00"
      }
    }
  ]
}
Required, validated
Optionnal

partner_ids

subtitle

title

  • en

  • fr

status

If not provided is set to 'active'.

If provided valid values are:

  • active

  • inactive

  • draft

  • approved

  • pending

  • done

details

  • en

  • fr

due_date

effective_date

priority

expires_at

expiration_blocks

  • due_soon

  • due_later

author_id

client_info

  • external_id

  • provider_name

  • company_name

  • module_name

redirect_url

category_action

Valid values:

  • validation

  • link

  • form

  • todo

  • schedule

type_action

Valid values:

  • validation

  • link

  • form

  • todo

  • schedule

action_group

Response:

{
    "status": "All actions successfully created",
    "statistics": {
        "total": 1,
        "successCount": 1,
        "partialSuccessCount": 0,
        "failureCount": 0
    },
    "actions": [
        {
            "actionNumber": 1,
            "status": "success",
            "successes": [
                {
                    "action_id": 19,
                    "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4"
                },
                {
                    "action_id": 20,
                    "external_id": "21d6955f-244e-439a-a432-a45d45ab8b34"
                }
            ],
            "errors": []
        }
    ]
}

We have two created actions therefore two returned action_ids because a new action will be created for each given id in partners_ids.


Example input of partial success 207 with 3 requests for actions:

{
    "data": [
        {
            "partner_ids": [
                "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "21d6955f-244e-439a-a432-a45d45ab8b34"
            ],
            "title": {
                "en": "Leave Approval",
                "fr": "Approbation de congé"
            },
            "subtitle": {
                "en": "Leave request for approval",
                "fr": "Demande de congé pour approbation"
            },
            "details": {
                "en": "Please approve the leave request via the external tool.",
                "fr": "Veuillez approuver la demande de congé via l'outil externe."
            },
            "status": "active",
            "effective_date": "2024-03-15 00:00:00",
            "due_date": "2024-01-19 06:51:15",
            "expires_at": "2024-03-18 00:09:30",
            "author_id": "not-integer-value",
            "client_info": {
                "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "provider_name": "CSOD",
                "company_name": "Sfam",
                "module_name": "EPM_PERF_REVIEW"
            },
            "redirect_url": "https://lucca.fr/action/validate?id=1234",
            "category_action": "link",
            "type_action": "link",
            "priority": "high",
            "action_group": "Sales Department",
            "expiration_blocks": {
                "due_soon": "2024-01-25 00:00:00",
                "due_later": "2024-12-31 00:00:00"
            }
        },
        {
            "partner_ids": [
                "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "21d6955f-244e-439a-a432-a45d45ab8b38"
            ],
            "title": {
                "en": "Leave Approval",
                "fr": "Approbation de congé"
            },
            "subtitle": {
                "en": "Leave request for approval",
                "fr": "Demande de congé pour approbation"
            },
            "details": {
                "en": "Please approve the leave request via the external tool.",
                "fr": "Veuillez approuver la demande de congé via l'outil externe."
            },
            "status": "active",
            "effective_date": "2024-03-15 00:00:00",
            "due_date": "2024-01-19 06:51:15",
            "expires_at": "2024-03-18 00:09:30",
            "author_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
            "client_info": {
                "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "provider_name": "CSOD",
                "company_name": "Sfam",
                "module_name": "EPM_PERF_REVIEW"
            },
            "redirect_url": "https://lucca.fr/action/validate?id=1234",
            "category_action": "link",
            "type_action": "link",
            "priority": "high",
            "action_group": "Sales Department",
            "expiration_blocks": {
                "due_soon": "2024-01-25 00:00:00",
                "due_later": "2024-12-31 00:00:00"
            }
        },
        {
            "partner_ids": [
                "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "21d6955f-244e-439a-a432-a45d45ab8b34"
            ],
            "title": {
                "en": "Leave Approval",
                "fr": "Approbation de congé"
            },
            "subtitle": {
                "en": "Leave request for approval",
                "fr": "Demande de congé pour approbation"
            },
            "details": {
                "en": "Please approve the leave request via the external tool.",
                "fr": "Veuillez approuver la demande de congé via l'outil externe."
            },
            "status": "active",
            "effective_date": "2024-03-15 00:00:00",
            "due_date": "2024-01-19 06:51:15",
            "expires_at": "2024-03-18 00:09:30",
            "author_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
            "client_info": {
                "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
                "provider_name": "CSOD",
                "company_name": "Sfam",
                "module_name": "EPM_PERF_REVIEW"
            },
            "redirect_url": "https://lucca.fr/action/validate?id=1234",
            "category_action": "link",
            "type_action": "link",
            "priority": "high",
            "action_group": "Sales Department",
            "expiration_blocks": {
                "due_soon": "2024-01-25 00:00:00",
                "due_later": "2024-12-31 00:00:00"
            }
        }
    ]
}

Response:

{
    "status": "Partial success: 2 action(s) created, 1 action(s) failed",
    "statistics": {
        "total": 3,
        "successCount": 1,
        "partialSuccessCount": 1,
        "failureCount": 1
    },
    "actions": [
        {
            "actionNumber": 1,
            "status": "error",
            "message": "400 Bad Request",
            "errors": {
                "author_id": [
                    "The selected author_id is invalid."
                ]
            }
        },
        {
            "actionNumber": 2,
            "status": "partial_success",
            "successes": [
                {
                    "action_id": 21,
                    "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4"
                }
            ],
            "errors": [
                {
                    "message": "Invalid input data",
                    "errors": {
                        "external_id": [
                            "invalid external_id"
                        ]
                    },
                    "external_id": "21d6955f-244e-439a-a432-a45d45ab8b38"
                }
            ]
        },
        {
            "actionNumber": 3,
            "status": "success",
            "successes": [
                {
                    "action_id": 22,
                    "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4"
                },
                {
                    "action_id": 23,
                    "external_id": "21d6955f-244e-439a-a432-a45d45ab8b34"
                }
            ],
            "errors": []
        }
    ]
}

Example input of complete failure 400 - error from the open-api-service:

{
  "data": [
    {
      "title": {
        "en": "Leave Approval",
        "fr": "Approbation de congé"
      },
      "subtitle": {
        "en": "Leave request for approval",
        "fr": "Demande de congé pour approbation"
      },
      "status": "active",
      "effective_date": "2024-03-15 00:00:00",
      "due_date": "2024-01-19 06:51:15",
      "expires_at": "2024-03-18 00:09:30",
      "author_id": "not-integer-value",
      "client_info": {
        "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
        "provider_name": "CSOD",
        "company_name": "Sfam",
        "module_name": "EPM_PERF_REVIEW"
      },
      "redirect_url": "https://lucca.fr/action/validate?id=1234",
      "category_action": "link",
      "type_action": "link",
      "priority": "high",
      "action_group": "Sales Department",
      "expiration_blocks": {
        "due_soon": "2024-01-25 00:00:00",
        "due_later": "2024-12-31 00:00:00"
      }
    }
  ]
}

Response:

{
    "httpStatus": "BAD_REQUEST",
    "exceptionName": "ActionValidationException",
    "message": "Error(s) occurred. Checkout 'errors' for more details.",
    "errors": [
        "Action #1 error - 'partner_ids' cannot be null or empty",
        "Action #1 error - 'details' cannot be null or empty"
    ],
    "timestamp": 1736427091296
}

Note: The request is validated on an open-API service level.

In this case, we may have multiple errors. No traffic to the core API will be generated.


Another example of failure 400 - error from the core API:

{
  "data": [
    {
      "partner_ids": [
        "6042dbca-93a4-418e-b625-b7da58eaf6d4",
        "21d6955f-244e-439a-a432-a45d45ab8b34"
      ],
      "title": {
        "en": "Leave Approval",
        "fr": "Approbation de congé"
      },
      "subtitle": {
        "en": "Leave request for approval",
        "fr": "Demande de congé pour approbation"
      },
      "details": {
        "en": "Please approve the leave request via the external tool.",
        "fr": "Veuillez approuver la demande de congé via l'outil externe."
      },
      "status": "active",
      "effective_date": "2024-03-15 00:00:00",
      "due_date": "2024-01-19 06:51:15",
      "expires_at": "2024-03-18 00:09:30",
      "author_id": "not-integer-value",
      "client_info": {
        "external_id": "6042dbca-93a4-418e-b625-b7da58eaf6d4",
        "provider_name": "CSOD",
        "company_name": "Sfam",
        "module_name": "EPM_PERF_REVIEW"
      },
      "redirect_url": "https://lucca.fr/action/validate?id=1234",
      "category_action": "link",
      "type_action": "link",
      "priority": "high",
      "action_group": "Sales Department",
      "expiration_blocks": {
        "due_soon": "2024-01-25 00:00:00",
        "due_later": "2024-12-31 00:00:00"
      }
    }
  ]
}

Response:

{
    "status": "All actions failed",
    "statistics": {
        "total": 1,
        "successCount": 0,
        "partialSuccessCount": 0,
        "failureCount": 1
    },
    "actions": [
        {
            "actionNumber": 1,
            "status": "error",
            "message": "400 Bad Request",
            "errors": {
                "author_id": [
                    "The selected author_id is invalid."
                ]
            }
        }
    ]
}

Key Points

  • Validation Stops All: If one payload fails open-api-service validation, no requests are sent to the legacy API.

  • Legacy API Mixed Responses: Errors from the legacy API do not block the processing of other payloads in the same request.

  • Detailed Statistics: Responses include success, failure, and partial success counts for transparency.

Note:

  • category_action and type_action currently maintain only the ‘link’ type.

Last updated