# Edit an artifact's source

Applies an oldText/newText batch as one commit. A miss rejects the whole batch and returns the CURRENT source, so the caller rebuilds its edits without another read.

## POST `/v1/artifacts/{ref}/edits`

### Authorization

`Authorization: Bearer <token>` - with the Space key (`sfc_` prefix), an API key (`sfa_` prefix), an OAuth access token, a session token, or a Space machine credential (`sfm_` prefix).

### Scopes:
`connectors:execute`

### Path parameters

- `ref`: string required

### Query parameters

- `team`: string min length 1

### Request body

- required `application/json`
  
```json
{
  "edits": [
    {
      "oldText": "string",
      "newText": "string"
    }
  ]
}
```

### Responses

#### 200 Response for status 200

```json
{
  "$schema": "string",
  "data": {
    "ref": "string",
    "spaceId": "string",
    "path": "string",
    "slug": "string",
    "title": "string",
    "description": "string",
    "owner": "team",
    "bindings": {
      "property1": "string",
      "property2": "string"
    },
    "commitSha": "string",
    "previewUrl": "string",
    "updatedAt": "2019-08-24T14:15:22Z",
    "source": "string",
    "parsedScopeNames": ["string"],
    "applied": true
  }
}
```

#### Error Response

```json
{
  "$schema": "string",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": ["string"],
  "next": ["string"],
  "requestId": "string"
}
```

## Try it

### cURL

```bash
curl -X POST "https://api.spacefast.com/v1/artifacts/string/edits" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "edits": [
    {
      "oldText": "string",
      "newText": "string"
    }
  ]
}'
```

### JavaScript

```javascript
const response = await fetch("https://api.spacefast.com/v1/artifacts/string/edits", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  },
  body: "{\n  \"edits\": [\n    {\n      \"oldText\": \"string\",\n      \"newText\": \"string\"\n    }\n  ]\n}"
});
```

### Python

```python
import requests

response = requests.post(
    "https://api.spacefast.com/v1/artifacts/string/edits",
    headers={
        "Authorization": "Bearer YOUR_TOKEN",
        "Content-Type": "application/json"
    },
    data="{\n  \"edits\": [\n    {\n      \"oldText\": \"string\",\n      \"newText\": \"string\"\n    }\n  ]\n}",
)
```
