> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://contentful.com/developers/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/developers/docs/_mcp/server.

# Create or update an asset

PUT https://api.contentful.com/spaces/{space_id}/environments/{environment_id}/assets/{asset_id}
Content-Type: application/vnd.contentful.management.v1+json

Creates a new asset with the specified ID or updates an existing one. When updating, include the current version in `X-Contentful-Version`.

Reference: https://contentful.com/developers/docs/references/content-management-api/assets/create-or-update-an-asset

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `space_id` (string, required) — ID of the Space in form of a string
- `environment_id` (string, required) — ID of the environment in form of a string
- `asset_id` (string, required) — ID of the Asset in form of a string

### Headers

- `X-Contentful-Version` (string, optional) — Version of the asset to update

### Body (application/vnd.contentful.management.v1+json)

This endpoint expects a map from string to any.

- `map from string to any`

## Response

### 201

Created - Resource created successfully

- `map from string to any`

## Examples

**Request**

```json
{
  "fields": {
    "file": {
      "en-US": {
        "contentType": "image/jpeg",
        "fileName": "example.jpeg",
        "upload": "https://example.com/example.jpg"
      }
    },
    "title": {
      "en-US": "Playsam Streamliner"
    }
  },
  "metadata": {
    "tags": [
      {
        "sys": {
          "id": "nyCampaign",
          "linkType": "Tag",
          "type": "Link"
        }
      }
    ]
  }
}
```

**Response**

```json
{
  "fields": {
    "file": {
      "en-US": {
        "contentType": "image/jpeg",
        "fileName": "example.jpeg",
        "upload": "https://example.com/example.jpg"
      }
    },
    "title": {
      "en-US": "Playsam Streamliner"
    }
  },
  "metadata": {
    "tags": [
      {
        "sys": {
          "id": "nyCampaign",
          "linkType": "Tag",
          "type": "Link"
        }
      }
    ]
  },
  "sys": {
    "createdAt": "2025-11-26T00:04:40.000Z",
    "createdBy": {
      "sys": {
        "id": "7BslKh9TdKGOK41VmLDjFZ",
        "linkType": "User",
        "type": "Link"
      }
    },
    "environment": {
      "sys": {
        "id": "staging",
        "linkType": "Environment",
        "type": "Link"
      }
    },
    "id": "wtrHxeu3zEoEce2MokCSi",
    "space": {
      "sys": {
        "id": "yadj1kx9rmg0",
        "linkType": "Space",
        "type": "Link"
      }
    },
    "type": "Asset",
    "updatedAt": "2025-11-26T00:04:40.000Z",
    "updatedBy": {
      "sys": {
        "id": "4FLrUHftHW3v2BLi9fzfjU",
        "linkType": "User",
        "type": "Link"
      }
    },
    "version": 1
  }
}
```

**SDK Code**

```android Android
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

// First: Fetch it!
client
    .assets()
    .async()
    .fetchOne(
        "<asset_id>",
        new CMACallback<CMAAsset>() {
          @Override protected void onSuccess(CMAAsset asset) {
            // Next: Change the asset.
            asset
                .getFields()
                .setDescription("en-US", "new description");

            client
                .assets()
                .async()
                .update(
                    asset,
                    new CMACallback<CMAAsset>() {
                      @Override protected void onSuccess(CMAAsset result) {
                        // Finally Done, your updated asset will be the parameter of this callback.
                        new AlertDialog.Builder(context)
                            .setTitle("Contentful")
                            .setMessage("Asset updated." +
                                "\n\nResult: " + result)
                            .show();
                      }

                      @Override protected void onFailure(RuntimeException exception) {
                        // An error occurred! Inform the user.
                        new AlertDialog.Builder(context)
                            .setTitle("Contentful Error")
                            .setMessage("Asset could not be updated." +
                                "\n\nReason: " + exception.toString())
                            .show();

                        super.onFailure(exception);
                      }
                    }
                );
          }

          @Override protected void onFailure(RuntimeException exception) {
            // An error occurred! Inform the user.
            new AlertDialog.Builder(context)
                .setTitle("Contentful Error")
                .setMessage("Could not fetch the asset." +
                    "\n\nReason: " + exception.toString())
                .show();

            super.onFailure(exception);
          }
        }
    );
```

```java Java
// Create the Contentful client.
final CMAClient client =
    new CMAClient
        .Builder()
        .setAccessToken("<access_token>")
        .setSpaceId("<space_id>")
        .setEnvironmentId("<environment_id>")
        .build();

// Fetch an existing asset.
final CMAAsset asset =
    client
        .assets()
        .fetchOne("<asset_id>");

// Update something
asset
    .getFields()
    .setDescription("en-US", "My Description");

client
    .assets()
    .update(asset);
```

```kotlin Kotlin
// Create the Contentful client.
val client = CMAClient.Builder()
    .setAccessToken("<access_token>")
    .setSpaceId("<space_id>")
    .setEnvironmentId("<environment_id>")
    .build()

// Fetch an existing asset.
val asset = client
        .assets()
        .fetchOne("<asset_id>")

// Update something
asset
        .fields
        .setDescription("en-US", "My Description")

client
        .assets()
        .update(asset)
```

```swift Swift
We currently don't provide a CMA SDK for this platform.
```

```js-legacy JavaScript (legacy)
import { createClient } from 'contentful-management'

const client = createClient({
  accessToken: '<content_management_api_key>'
}, { type: 'legacy' })

// Create asset
client.getSpace('<space_id>')
.then((space) => space.getEnvironment('<environment_id>'))
.then((environment) => environment.createAsset({
  fields: {
    title: {
      'en-US': 'Playsam Streamliner'
    },
    description: {
      'en-US': 'Streamliner description'
    },
    file: {
      'en-US': {
        contentType: 'image/jpeg',
        fileName: 'example.jpeg',
        upload: 'https://example.com/example.jpg'
      }
    }
  }
}))
.then((asset) => asset.processForAllLocales())
.then((asset) => console.log(asset))
.catch(console.error)

// Update asset
client.getSpace('<space_id>')
.then((space) => space.getEnvironment('<environment_id>'))
.then((environment) => environment.getAsset('<asset_id>'))
.then((asset) => {
  asset.fields.title['en-US'] = 'New asset title'
  return asset.update()
})
.then((asset) => console.log(`Asset ${asset.sys.id} updated.`))
.catch(console.error)
```

```javascript JavaScript
import { createClient } from 'contentful-management'

// Client init
const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})

// Create asset
let asset = await client.asset.create(
  {
    spaceId: '<space_id>',
    environmentId: '<environment_id>',
  },
  {
    fields: {
      title: {
        'en-US': 'Asset title',
      },
      description: {
        'en-US': 'Asset description',
      },
      file: {
        'en-US': {
          contentType: 'image/jpeg',
          fileName: 'example.jpeg',
          upload: 'https://example.com/example.jpg',
        },
      },
    },
  }
);

// Update asset
asset = await client.asset.update(
  {
    spaceId: '<space_id>',
    environmentId: '<environment_id>',
    assetId: '<asset_id>',
  },
  {
    sys: asset.sys,
    fields: {
      ...asset.fields,
      title: {
        'en-US': 'Updated asset title',
      },
    },
  }
);
```

```php PHP
$client = new \Contentful\Management\Client('<content_management_api_key>');

$environment = $client->getEnvironmentProxy('<space_id>', '<environment_id>');

// Create the link to a file
$file = new \Contentful\Core\File\RemoteUploadFile(
  'image.png', // File name
  'image/png', // Mime type
  'https://example.com/image.png' // URL where the file is located
);

// Create the actual asset
$asset = new \Contentful\Management\Resource\Asset();
$asset->setTitle('en-US', 'Asset title')
    ->setDescription('en-US', 'Asset description')
    ->setFile('en-US', $file);

$environment->create($asset);

$asset->setTitle('en-US', 'New asset title');
$asset->update();
```

```ruby Ruby
require 'contentful/management'

client = Contentful::Management::Client.new('<content_management_api_key>')

# Create an asset:
file = Contentful::Management::File.new
file.properties[:contentType] = 'image/jpeg'
file.properties[:fileName] = 'pic1.jpg'
file.properties[:upload] = 'https://upload.wikimedia.org/wikipedia/commons/c/c7/Gasometer_Berlin_Sch%C3%B6neberg_2011.jpg'

asset = client.assets('<space_id>', '<environment_id>').create(
  title: 'Asset title',
  description: 'Asset description',
  file: file
)

# Update an asset:
asset.title = 'New asset title'
asset.save
```

```python Python
from contentful_management import Client

client = Client('<content_management_api_key>')

# Create an Asset:
asset_id = '<asset_id>'  # Use `None` if you want the API to autogenerate the ID.
asset = client.assets('<space_id>', '<environment_id>').create(asset_id, {
    'fields': {
        'title': {
            'en-US': 'Playsam Streamliner'
        },
        'file': {
            'en-US': {
                'contentType': 'image/jpeg',
                'fileName': 'example.jpeg',
                'upload': 'https://example.com/example.jpg'
            }
        }
    }
})

# Update an Asset:
asset.title = 'New asset title'
asset.save()
```

```.net .NET
// This client should only be created once per application.
var httpClient = new HttpClient();

var client = new ContentfulManagementClient(httpClient, "<content_management_api_key>", "<space_id>");

var asset = new ManagementAsset();
managementAsset.SystemProperties = new SystemProperties();
managementAsset.SystemProperties.Id = "<new_asset_id>";

managementAsset.Title = new Dictionary<string, string> {
    { "en-US", "New asset" },
    { "sv-SE", "Ny tillgång" }
};

managementAsset.Files = new Dictionary<string, File>
{
    { "en-US", new File() {
            ContentType = "image/png",
            FileName = "image.png",
            UploadUrl = "https://example.com/image.png"
        }
    },
    { "sv-SE", new File() {
            ContentType = "image/png",
            FileName = "image.png",
            UploadUrl = "https://example.com/image-SE.png"
        }
    }
};

await client.CreateOrUpdateAsset(managementAsset);
```