/api/v1/tenants/[id]/services/enable (management)
Source-derived management endpoint contract, authentication, request validation, responses, and errors.
This is the management service route. Its origin and authentication are described in Platform API overview and Authentication. A path shared by another service is a different endpoint.
| Property | Contract |
|---|---|
| Methods | POST |
| Path | /api/v1/tenants/[id]/services/enable |
| Path parameters | id |
| Query parameters read in route | None read directly; schema validation below may define additional fields |
| Headers read in route | No additional direct header reads; authentication helpers may read credentials |
Authentication and access
Management auth context: validated x-api-key or configured session authentication; trusted gateway integration may select its auth pipeline. Organization/tenant checks are separate.
Request and response definitions
The following named definitions are imported or declared by this route. Optional markers, defaults, bounds, and enum values are shown exactly as implemented. A response type is a source contract, not an example populated with real account data.
MultiInstanceEnableRequest
export interface MultiInstanceEnableRequest {
services: ServiceName[];
instanceSelection: InstanceSelection;
rollout: RolloutOptions;
verifyHealth?: boolean; // Default: true
}Source: minds-ui/apps/api-service/lib/services/multi-instance-orchestrator.ts:44.
Method behavior
The handler excerpt preserves field validation, response envelopes, cookie changes, and exception branches. Values returned by service helpers retain their named response type above; for passthrough routes, the upstream response is authoritative.
POST
export async function POST(
request: NextRequest,
{ params }: { params: { tenantId: string } }
) {
try {
const authContext = await resolveAuthContext(request, {
allowApiKey: true,
allowSession: true,
});
const { tenantId } = params;
// Verify tenant access
const tenant = await prisma.tenant.findUnique({ where: { id: tenantId } });
if (!tenant) {
return NextResponse.json({ error: 'Tenant not found' }, { status: 404 });
}
await ensureTenantAccess(authContext, tenant.orgId, tenant.ownerId, {
action: 'instance:manage',
tenantId: tenant.id,
resourceId: tenant.id,
attributes: { operation: 'tenant-wide-service-enable' },
});
const body = await request.json();
// Validate request body
if (!body.services || !Array.isArray(body.services)) {
throw new InvalidRequestError('services array required');
}
if (!body.instanceSelection || !body.instanceSelection.mode) {
throw new InvalidRequestError('instanceSelection.mode required');
}
if (!body.rollout || !body.rollout.type) {
throw new InvalidRequestError('rollout.type required');
}
const enableRequest: MultiInstanceEnableRequest = {
services: body.services,
instanceSelection: body.instanceSelection,
rollout: body.rollout,
verifyHealth: body.verifyHealth !== false,
};
// Enable services on multiple instances
const result = await multiInstanceOrchestrator.enableServicesOnMultipleInstances(
tenantId,
enableRequest,
authContext.userId
);
return NextResponse.json(result);
} catch (error) {
if (error instanceof ApiError) {
return NextResponse.json(
{ error: error.message },
{ status: error.statusCode }
);
}
console.error('[API] Error enabling services on multiple instances:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:13.
Response and error branches
Literal HTTP statuses in the route: 404, 500. Shared management error classes are defined in Errors and responses.
NextResponse.json({ error: 'Tenant not found' }, { status: 404 })Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:28.
request.json()Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:38.
new InvalidRequestError('services array required')Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:42.
new InvalidRequestError('instanceSelection.mode required')Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:46.
new InvalidRequestError('rollout.type required')Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:50.
NextResponse.json(result)Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:67.
NextResponse.json(
{ error: error.message },
{ status: error.statusCode }
)Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:70.
NextResponse.json({ error: 'Internal server error' }, { status: 500 })Source: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts:77.
Service dependencies
minds-ui/apps/api-service/lib/services/auth-context.tsminds-ui/apps/api-service/lib/services/multi-instance-orchestrator.tsminds-ui/apps/api-service/types/errors.tsminds-ui/apps/api-service/lib/db.ts
Evidence
Generated from the local source snapshot on 2026-09-12. This page documents implemented code and does not certify a deployed service, permissions configuration, or successful provider operation.
Source file: minds-ui/apps/api-service/app/api/v1/tenants/[id]/services/enable/route.ts. SHA-256: 7f54a2240b9d2dc91d4df70d13d1bca5d80ebd67518b1854528f21e4c4f43b77.