Skip to content
Reference

External operations

Submit registered HTTP, MCP and signed webhook operations from an App container.

External operations

Use Nexia\Integrations\Contracts\ExternalIntegrations for an operation that a workspace administrator registered and explicitly shared with your App. Core holds the destination and credentials. The current human actor must have connection-use permission; an App installation alone does not grant it.

Declare an HTTP API in App code

An App contribution implementing ExternalApiContribution exports connection definitions to the runtime catalog. Its key starts with the App key. An authorized administrator reviews and applies the definition under Settings → External connections → API. A declaration alone creates no connection, secret, or execution authority.

Code example
PHP
use Nexia\Integrations\Contracts\ExternalApiContribution;
use Nexia\Integrations\ExternalApiDefinition;

final class ShippingApi implements ExternalApiContribution
{
    public static function externalApis(): array
    {
        return [new ExternalApiDefinition(
            key: 'shipping.provider', name: 'Shipping API', purpose: 'Book and track shipments',
            scope: 'legal_entity', endpointUrl: 'https://api.shipping.example',
            operations: [[
                'name' => 'create_shipment', 'method' => 'POST', 'path' => '/shipments',
                'input_schema' => ['type' => 'object'], 'enabled' => false, 'agent_enabled' => false,
            ]],
            receiver: ['mode' => 'webhook', 'expires_days' => 30, 'input_schema' => ['type' => 'object']],
            authentication: ['type' => 'api_key', 'header' => 'x-api-key'],
        )];
    }
}

endpointUrl and operations describe Nexia calling an external service. For receiving only, set endpointUrl: null, operations: [], and provide receiver. The receiver suggests the inbound mode, expiry, and input schema. An administrator must choose a published Process and message waiting step, issue the endpoint, and grant its receiving authority separately. This does not create a general App API or CRUD endpoint.

The connection's enabled and each operation's enabled and agent_enabled are suggested initial states that an administrator may change. authentication suggests a supported type (bearer, api_key, or webhook_hmac) and an API key header. The administrator enters the secret directly into Nexia; App code cannot read it. Each legal entity applies the definition separately. Later changes to an App definition do not overwrite an applied connection or an administrator's settings. An administrator can approve automatic application of the same definition on reinstall, either while applying it or from an existing connection. Approval is pinned to the definition's digest. A changed address, operation, or initial setting requires a fresh review. Revoking approval stops future automatic application and leaves the existing connection intact. Reinstallation does not overwrite an existing connection.

An App can submit an applied operation by stable key instead of storing a connection UUID. Declare integration.submit_declared and integration.result in the App work handler's platform_callbacks.

Code example
PHP
use Nexia\Integrations\Contracts\ExternalIntegrations;

$executionId = app(ExternalIntegrations::class)->submitDeclared(
    $actor, 'shipping.provider', 'create_shipment', $legalEntityPublicId,
    ['order' => $orderId], $requestKey,
);

Submit after committing App work

In an App work handler, declare integration.submit and integration.result in its platform_callbacks. Call outside the App database transaction, using the invocation's current actor. The container runtime sends authenticated callbacks to Core; App code does not import Core models or obtain connection credentials.

Code example
PHP
use Nexia\Integrations\Contracts\ExternalIntegrations;

// Inside authorized App work, after its business transaction has committed.
$external = app(ExternalIntegrations::class);
$executionId = $external->submit($actor, $operationPublicId, ['order' => $orderId], $requestKey);
$result = $external->result($actor, $executionId);

Use a durable business request key and preserve it when retrying submission. Identical input returns the same execution; changed input with the same key is rejected. Submission returns an ID, not remote success. Poll through bounded, scheduled App work, not a tight loop.

StatusMeaning
queued / runningWaiting or executing
retryingA signed webhook is waiting for its next bounded delivery attempt
succeededThe registered operation returned success
failedA remote failure was returned, or webhook attempts ended
cancelledCurrent authorization, installation or configuration no longer permits execution
unknownThe remote effect may have happened; reconcile before a new request

Only the originating App and actor with current access can read the result. Do not log its business payload. Core checks current permissions, App sharing and configuration revisions before execution; revocation cannot recall a request already sent.

For MCP operations, Core validates submitted input against the provider's current tool schema immediately before the call. A failed result with invalid_tool_input means no tool call was sent; update the input for the provider's current schema and submit a new intended request with a new idempotency key. A tool_contract_changed failure also means no tool call was sent. An unknown result remains uncertain and must be reconciled before any new request.

Process Tasks and incoming messages

Administrators may select registered operations directly in Process service Tasks. Apps do not need to declare another Work Action for the same connection. Core waits for the external result and delivers it through the durable Process inbox.

Receiving endpoints are separate credentials and principals scoped to one legal entity, process definition and message-waiting step. Issuing a key does not grant receiving authority. API requests use Bearer authentication and Idempotency-Key; signed webhooks use webhook-id, webhook-timestamp and webhook-signature over the exact body. Both carry process_instance_id, payload and an optional reference_id. A 202 receipt acknowledges delivery acceptance, not overall process completion. The endpoint does not start a process or expose arbitrary resource CRUD.

MCP OAuth and mail ownership

Remote MCP credentials may use discovered OAuth authorization-code flows with PKCE S256. Core supports public-client registration where advertised, or registered clients using none, client_secret_basic or client_secret_post. Core stores and refreshes tokens; an App receives neither tokens nor client secrets and needs no OAuth callback of its own. Providers requiring other client authentication methods or lacking compatible discovery need a different supported authentication method. Revocation in Nexia removes local credentials; provider grant revocation remains separate.

Business mail uses the owning email contracts and prefers tenant/Legal Entity SMTP. If no business sender is configured and no explicit sender restriction applies, it uses the platform mail settings. Disabled or forbidden configured senders remain blocked; an SMTP failure never triggers a second send through the platform. Agent email is a Core tool with exact-content confirmation, live permission checks and encrypted delivery evidence, not a new unrestricted App mail API. Login invitations, including People invitations, follow this business-first policy. Password recovery remains on the platform sender. Tenant administrators can inspect unified mail metadata with tenant.notification_delivery.read; this does not expose message bodies or grant business-resource access. SMTP acceptance does not establish inbox delivery.

Administrators applying App declarations can use the external connections guide to configure credentials and permissions. See the external connections update for the user-facing changes.

Source of truth: docs/developers/content/en/app-sdk/external-integrations.md