---
title: "Duplicate snippet"
method: POST
path: "/workspaces/{workspace_id}/snippets/{snippet_id}/duplicate"
tags: ["Snippets"]
---

# Duplicate snippet

`POST /workspaces/{workspace_id}/snippets/{snippet_id}/duplicate`

## Request

- Base URL: `https://app.mammoth.io/api/v2`
- URL: `https://app.mammoth.io/api/v2/workspaces/{workspace_id}/snippets/{snippet_id}/duplicate`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-KEY` and API key in header `X-API-SECRET` and API key in header `X-WORKSPACE-ID`

Create a copy of an existing snippet

## Path parameters

- `workspace_id` integer, required: Workspace refers to a collection of projects. Workspace ID is unique identifier for workspace.
- `snippet_id` integer, required

## Response `201`

Duplicate SnippetResponse

- SnippetResponse
  - `id` integer, required: Snippet ID
  - `name` string, required: Snippet name
  - `code` string, required: Snippet source code
  - `language` string, required: Snippet language
  - `description` string, nullable: Snippet description
  - `scope` string, required: Scope of the snippet
  - `group_id` integer, nullable: Parameter group ID
  - `group_name` string, nullable: Name of the parameter group
  - `pipeline_count` integer, required: Number of pipelines using this snippet
  - `stale_pipelines` integer[]: Dataview IDs of stale pipelines using this snippet
  - `referenced_parameters` string[], required: Names of parameters used in the snippet code
  - `created_by` integer, required: User ID who created the snippet
  - `created_at` string, required: Creation timestamp
  - `updated_by` integer, nullable: User ID who last updated the snippet
  - `updated_at` string, required: Last update timestamp

## Other responses

- `400`: Bad Request
- `401`: Authorization error
- `403`: Request forbidden -- authorization will not help

---

[API](https://skmtc.dev/mammoth/apis/mammoth-analytics.md) · [All operations](https://skmtc.dev/mammoth/apis/mammoth-analytics/llms.txt) · [OpenAPI document](https://skmtc.dev/mammoth/apis/mammoth-analytics/revisions/5dfd1c296ded?raw)
