---
updatedAt: 2025-09-24T21:32:16.000Z
agentTools:
  projectIndex: https://developers.transifex.com/llms.txt
---

# Create, update and delete a resource in NodeJS

```javascript JavaScript
/*
 * Use the Transifex API SDK from npm:
 * https://www.npmjs.com/package/@transifex/api
 * 
 * Install the SDK using npm:
 * npm install @transifex/api
 *
 * Optionally install axios for downloading resources:
 * npm install axios
 */

const { transifexApi } = require('@transifex/api');
const axios = require('axios');

// API token authentication
transifexApi.setup({ auth: '<YOUR-API-TOKEN>' });

async function main() {
  // Get the organization and project models
  const organization = await transifexApi.Organization.get({ slug: '<YOUR-ORG-SLUG>' });
  const projects = await organization.fetch('projects');
  const project = await projects.get({ slug: '<YOUR-PROJECT-SLUG>' });

  // Create a new resource
  const i18n_format = await transifexApi.i18n_formats.get({
    organization: organization,
    name: 'KEYVALUEJSON'
  })

  const resource = await transifexApi.Resource.create({
    name: '<NEW-RESOURCE-NAME>',
    slug: '<NEW-RESOURCE-SLUG>',
    i18n_format: i18n_format,
    project: project,
  });

  // Upload content
  const content = JSON.stringify({ 'key': 'value' });
  await transifexApi.ResourceStringsAsyncUpload.upload({
    resource: resource, 
    content: content,
  });

  // Download translated content
  const language = await transifexApi.Language.get({ code: 'fr' });

  const url = await transifexApi.ResourceTranslationsAsyncDownload
    .download({
      resource: resource, 
      language: language
    });

  const translated_content = (await axios.get(url)).data;
  console.log(translated_content);

  // Delete resource
  await resource.delete();
}

main();

```

```json Response Example
{"success":true}
```

# Install the SDK

<!-- javascript@1-10 -->

Install the Transifex Javascript SDK from [NPM](https://www.npmjs.com/package/@transifex/api), using the following command in the terminal:

```
npm install @transifex/api
```

# Setup authentication

<!-- javascript@12-16 -->

Create an API token from your [user settings page](https://www.transifex.com/user/settings/api/) in Transifex and initialize the SDK.

# Retrieve the project

<!-- javascript@19-22 -->

Use the SDK to get the organization and project model you want to manage.

# Create a new resource

<!-- javascript@24-35 -->

Add a new resource to the project by selecting an i18n file format and setting the resource name and slug.

# Add some content

<!-- javascript@37-42 -->

Upload some content to the resource. The content must be compatible with the selected i18n format. This is usually read by a file.

> On this example, we have chosen the KEYVALUEJSON format.

# Download translations

<!-- javascript@44-54 -->

Retrieve the model of the target language, pass it as parameter to async downloads API. This will trigger a job to generated the translated file.

Use the returned URL to download the actual file, translated in the target language.

# Delete a resource

<!-- javascript@56-57 -->

Delete the resource by using the `delete()` method on a resource model.