# Script Versions

## Get Script Version

> Retrieves the details of a specific script version.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ScriptVersionsResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ScriptVersions"}}},"ScriptVersions":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script_id":{"type":"integer"},"name":{"type":"string"},"version":{"type":"integer"},"status":{"type":"string","enum":["Draft","Inactive","Deployed"]},"deployment_failure_reason":{"type":"string"},"last_invoked_on":{"type":"string"},"deployed_at":{"type":"string","format":"date-time"},"deployment_failed_at":{"type":"string","format":"date-time"},"deploying":{"type":"string"},"content":{"type":"object"},"script":{"type":"object"}}}}},"paths":{"/api/v1/script-versions/{script_version}":{"get":{"summary":"Get Script Version","description":"Retrieves the details of a specific script version.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."},{"name":"filter[is_deployed]","in":"query","required":false,"schema":{"type":"string"},"description":"Filter results by is_deployed."},{"name":"filter[deployed_at]","in":"query","required":false,"schema":{"type":"string"},"description":"Filter results by deployed_at."},{"name":"include","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated list of relationships to include. Available: content, script"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1},"description":"Page number for pagination."},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100},"description":"Number of results per page."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsResponse"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"}},"tags":["Script Versions"]}}}}
```

## Delete Script Version

> Permanently deletes a specific script version.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"MessageResponse":{"type":"object","properties":{"message":{"type":"string"}}}}},"paths":{"/api/v1/script-versions/{script_version}":{"delete":{"summary":"Delete Script Version","description":"Permanently deletes a specific script version.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"}},"tags":["Script Versions"]}}}}
```

## Upload Script Version

> Uploads a given script version to your \`private\` marketplace.\
> \
> This operation requires \`administrator\` permissions. If you are authorising requests with an API key, this request won't work (company-level API keys are associated with manager-level permissions). If you are an \`administrator\`, you can use OAuth 2 credentials to complete this operation. For more information please see our \[Authentication]\(<https://doc.wearepatchworks.com/product-documentation/api-reference/getting-started/authentication#oauth-2-client-credentials>) section.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"ScriptVersionsScriptUploadUploadRequest":{"type":"object","properties":{"private":{"type":"string"}}}}},"paths":{"/api/v1/script-versions/{script_version}/upload":{"post":{"summary":"Upload Script Version","description":"Uploads a given script version to your `private` marketplace.\n\nThis operation requires `administrator` permissions. If you are authorising requests with an API key, this request won't work (company-level API keys are associated with manager-level permissions). If you are an `administrator`, you can use OAuth 2 credentials to complete this operation. For more information please see our [Authentication](https://doc.wearepatchworks.com/product-documentation/api-reference/getting-started/authentication#oauth-2-client-credentials) section.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsScriptUploadUploadRequest"}}}},"tags":["Script Versions"]}}}}
```

## Deploy Script Version

> Deploys a specific script version.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}},"paths":{"/api/v1/script-versions/{script_version}/deploy":{"post":{"summary":"Deploy Script Version","description":"Deploys a specific script version.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"tags":["Script Versions"]}}}}
```

## Invoke Script Version

> Invokes a specific script version.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"ScriptVersionsInvokeInvokeRequest":{"type":"object","properties":{"variables":{"type":"string"},"payload":{"type":"string"},"flow":{"type":"string","properties":{"variables":{"type":"string"}}}}}}},"paths":{"/api/v1/script-versions/{script_version}/invoke":{"post":{"summary":"Invoke Script Version","description":"Invokes a specific script version.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsInvokeInvokeRequest"}}}},"tags":["Script Versions"]}}}}
```

## List Script Version Logs

> Retrieves a list of logs for a specific script version.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ScriptVersionsListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ScriptVersions"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"},"links":{"$ref":"#/components/schemas/PaginationLinks"}}},"ScriptVersions":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script_id":{"type":"integer"},"name":{"type":"string"},"version":{"type":"integer"},"status":{"type":"string","enum":["Draft","Inactive","Deployed"]},"deployment_failure_reason":{"type":"string"},"last_invoked_on":{"type":"string"},"deployed_at":{"type":"string","format":"date-time"},"deployment_failed_at":{"type":"string","format":"date-time"},"deploying":{"type":"string"},"content":{"type":"object"},"script":{"type":"object"}}},"PaginationMeta":{"type":"object","properties":{"current_page":{"type":"integer"},"from":{"type":"integer","nullable":true},"last_page":{"type":"integer"},"path":{"type":"string"},"per_page":{"type":"integer"},"to":{"type":"integer","nullable":true},"total":{"type":"integer"}}},"PaginationLinks":{"type":"object","properties":{"first":{"type":"string","format":"uri"},"last":{"type":"string","format":"uri"},"prev":{"type":"string","format":"uri","nullable":true},"next":{"type":"string","format":"uri","nullable":true}}}}},"paths":{"/api/v1/script-versions/{script_version}/logs":{"get":{"summary":"List Script Version Logs","description":"Retrieves a list of logs for a specific script version.","parameters":[{"name":"script_version","in":"path","required":true,"schema":{"type":"string"},"description":"The script version identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsListResponse"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"}},"tags":["Script Versions"]}}}}
```

## List Script Versions

> Retrieves a paginated list of versions for a specific script. Can be filtered by \`is\_deployed\` and \`deployed\_at\`.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ScriptVersionsListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ScriptVersions"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"},"links":{"$ref":"#/components/schemas/PaginationLinks"}}},"ScriptVersions":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script_id":{"type":"integer"},"name":{"type":"string"},"version":{"type":"integer"},"status":{"type":"string","enum":["Draft","Inactive","Deployed"]},"deployment_failure_reason":{"type":"string"},"last_invoked_on":{"type":"string"},"deployed_at":{"type":"string","format":"date-time"},"deployment_failed_at":{"type":"string","format":"date-time"},"deploying":{"type":"string"},"content":{"type":"object"},"script":{"type":"object"}}},"PaginationMeta":{"type":"object","properties":{"current_page":{"type":"integer"},"from":{"type":"integer","nullable":true},"last_page":{"type":"integer"},"path":{"type":"string"},"per_page":{"type":"integer"},"to":{"type":"integer","nullable":true},"total":{"type":"integer"}}},"PaginationLinks":{"type":"object","properties":{"first":{"type":"string","format":"uri"},"last":{"type":"string","format":"uri"},"prev":{"type":"string","format":"uri","nullable":true},"next":{"type":"string","format":"uri","nullable":true}}}}},"paths":{"/api/v1/scripts/{script}/script-versions":{"get":{"summary":"List Script Versions","description":"Retrieves a paginated list of versions for a specific script. Can be filtered by `is_deployed` and `deployed_at`.","parameters":[{"name":"script","in":"path","required":true,"schema":{"type":"string"},"description":"The script identifier."},{"name":"filter[is_deployed]","in":"query","required":false,"schema":{"type":"string"},"description":"Filter results by is_deployed."},{"name":"filter[deployed_at]","in":"query","required":false,"schema":{"type":"string"},"description":"Filter results by deployed_at."},{"name":"include","in":"query","required":false,"schema":{"type":"string"},"description":"Comma-separated list of relationships to include. Available: content, script"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1},"description":"Page number for pagination."},{"name":"per_page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100},"description":"Number of results per page."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsListResponse"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"}},"tags":["Script Versions"]}}}}
```

## Create Script Version

> Creates a new version for a specific script.

```json
{"openapi":"3.0.0","info":{"title":"Patchworks Core API","version":"1.0.0"},"tags":[{"name":"Script Versions"}],"servers":[{"url":"https://core.wearepatchworks.com"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"API key passed in the Authorization header. Format: `<api-key>`"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"OAuth 2 Bearer token obtained from POST /fabric/api/login"}},"schemas":{"ScriptVersionsResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ScriptVersions"}}},"ScriptVersions":{"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"script_id":{"type":"integer"},"name":{"type":"string"},"version":{"type":"integer"},"status":{"type":"string","enum":["Draft","Inactive","Deployed"]},"deployment_failure_reason":{"type":"string"},"last_invoked_on":{"type":"string"},"deployed_at":{"type":"string","format":"date-time"},"deployment_failed_at":{"type":"string","format":"date-time"},"deploying":{"type":"string"},"content":{"type":"object"},"script":{"type":"object"}}},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"errors":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}},"ScriptsStoreScriptVersionsRequest":{"type":"object","properties":{"content":{"type":"string","minLength":1}},"required":["content"]}}},"paths":{"/api/v1/scripts/{script}/script-versions":{"post":{"summary":"Create Script Version","description":"Creates a new version for a specific script.","parameters":[{"name":"script","in":"path","required":true,"schema":{"type":"string"},"description":"The script identifier."}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptVersionsResponse"}}}},"401":{"description":"Unauthenticated"},"403":{"description":"Unauthorized"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScriptsStoreScriptVersionsRequest"}}}},"tags":["Script Versions"]}}}}
```
