Blueprints

Manage an existing resource with Blueprints

Learn how to bring an existing Sanity resource under Blueprints stack management, and how to release a resource without destroying it.

If you have a Sanity resource that exists outside of a stack, you can bring it under stack management without recreating it. Once attached, Blueprints manages the resource like any other resource in your stack.

Prerequisites

  • An existing blueprint. See Blueprints introduction if you haven't set one up yet.
  • The identifier of the resource you want to attach.
  • For project-scoped resources, the project ID the resource belongs to.

Attach the resource

Add the resource to your blueprint with ownershipAction set to attach.

import { defineBlueprint, defineDataset } from "@sanity/blueprints"

export default defineBlueprint({
  resources: [
    defineDataset({
      name: 'production',
      datasetName: 'production',
      lifecycle: {
        ownershipAction: {
          type: 'attach',
          id: 'your-resource-id',
          projectId: 'your-project-id',
        },
      },
    }),
  ],
})

The id field is the identifier of the existing resource. For project-scoped resources, include projectId as well.

Deploy the blueprint to complete the attachment.

npx sanity blueprints deploy

After the deployment, the resource is managed by the stack. Future deployments will update it alongside any other resources in your blueprint.

You can remove ownershipAction from the resource definition once the attachment is complete. Leaving it in has no effect on subsequent deployments.

Release a resource without destroying it

If you want to stop managing a resource but keep it running, use detach. Blueprints removes the resource from the stack without deleting it from Sanity.

import { defineBlueprint, defineDataset } from "@sanity/blueprints"

export default defineBlueprint({
  resources: [
    defineDataset({
      name: 'production',
      datasetName: 'production',
      lifecycle: {
        ownershipAction: {
          type: 'detach',
        },
      },
    }),
  ],
})

Deploy the blueprint to detach the resource.

npx sanity blueprints deploy

Once the deployment completes, remove the resource definition from your blueprint.

How detach works across deploys

Blueprints evaluates your blueprint fresh on every deploy. After a resource is detached, it is no longer part of the stack. On the next deploy, if that resource still appears in your blueprint without ownershipAction, Blueprints sees a name with no matching stack record and creates a new resource in its place.

Detaching always takes two deploys: one to release the resource, and one to remove it from your blueprint. Between those two deploys, keep ownershipAction: { type: 'detach' } on the resource. Blueprints will ignore it rather than recreate it.

✅ Use detach before destroying a stack if you want to preserve specific resources.

❌ Don't remove a resource from the blueprint without setting ownershipAction to detach first. Blueprints will destroy it.

❌ Don't remove ownershipAction from a resource while it is still in your blueprint after detaching. Blueprints will treat it as a new resource and create it again.

Was this page helpful?

Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change site theme