> ## Documentation Index
> Fetch the complete documentation index at: https://novu-c5de82d9-docs-homepage-redesign.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a translation

> Create a translation using the Novu REST API. Requires your environment secret key in the Authorization header.



## OpenAPI

````yaml POST /v2/translations
openapi: 3.0.0
info:
  title: Novu API
  description: >-
    Novu REST API. Please see https://docs.novu.co/api-reference for more
    details.
  version: 3.15.0
  contact:
    name: Novu Support
    url: https://discord.gg/novu
    email: support@novu.co
  termsOfService: https://novu.co/terms
  license:
    name: MIT
    url: https://opensource.org/license/mit
servers:
  - url: https://api.novu.co
  - url: https://eu.api.novu.co
security:
  - secretKey: []
tags:
  - name: Events
    description: >-
      Events represent a change in state of a subscriber. They are used to
      trigger workflows, and enable you to send notifications to subscribers
      based on their actions.
    externalDocs:
      url: https://docs.novu.co/workflows
  - name: Subscribers
    description: >-
      A subscriber in Novu represents someone who should receive a message. A
      subscriber's profile information contains important attributes about the
      subscriber that will be used in messages (name, email). The subscriber
      object can contain other key-value pairs that can be used to further
      personalize your messages.
    externalDocs:
      url: https://docs.novu.co/subscribers/subscribers
  - name: Topics
    description: >-
      Topics are a way to group subscribers together so that they can be
      notified of events at once. A topic is identified by a custom key. This
      can be helpful for things like sending out marketing emails or notifying
      users of new features. Topics can also be used to send notifications to
      the subscribers who have been grouped together based on their interests,
      location, activities and much more.
    externalDocs:
      url: https://docs.novu.co/subscribers/topics
  - name: Integrations
    description: >-
      With the help of the Integration Store, you can easily integrate your
      favorite delivery provider. During the runtime of the API, the
      Integrations Store is responsible for storing the configurations of all
      the providers.
    externalDocs:
      url: https://docs.novu.co/platform/integrations/overview
  - name: Workflows
    description: >-
      All notifications are sent via a workflow. Each workflow acts as a
      container for the logic and blueprint that are associated with a type of
      notification in your system.
    externalDocs:
      url: https://docs.novu.co/workflows
  - name: Messages
    description: >-
      A message in Novu represents a notification delivered to a recipient on a
      particular channel. Messages contain information about the request that
      triggered its delivery, a view of the data sent to the recipient, and a
      timeline of its lifecycle events. Learn more about messages.
    externalDocs:
      url: https://docs.novu.co/workflows/messages
  - name: Environments
    description: >-
      Environments allow you to manage different stages of your application
      development lifecycle. Each environment has its own set of API keys and
      configurations, enabling you to separate development, staging, and
      production workflows.
    externalDocs:
      url: https://docs.novu.co/platform/environments
  - name: Layouts
    description: Layouts are reusable wrappers for your email notifications.
    externalDocs:
      url: https://docs.novu.co/platform/workflow/layouts
  - name: Translations
    description: Used to localize your notifications to different languages.
    externalDocs:
      url: https://docs.novu.co/platform/workflow/advanced-features/translations
  - name: Domains
    description: Used to manage your inbound email domains.
    externalDocs:
      url: https://docs.novu.co/platform/domains
externalDocs:
  description: Novu Documentation
  url: https://docs.novu.co
paths:
  /v2/translations:
    post:
      tags:
        - Translations
      summary: Create a translation
      description: >-
        Create a translation for a specific workflow and locale, if the
        translation already exists, it will be updated
      operationId: TranslationController_createTranslationEndpoint
      parameters:
        - name: idempotency-key
          in: header
          description: A header for idempotency purposes
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTranslationRequestDto'
      responses:
        '200':
          description: Translation created or updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TranslationResponseDto'
      security:
        - secretKey: []
        - secretKey: []
      x-codeSamples:
        - lang: php
          label: PHP
          source: >-
            declare(strict_types=1);


            require 'vendor/autoload.php';


            use novu;

            use novu\Models\Components;


            $sdk = novu\Novu::builder()
                ->setSecurity(
                    'YOUR_SECRET_KEY_HERE'
                )
                ->build();

            $createTranslationRequestDto = new
            Components\CreateTranslationRequestDto(
                resourceId: 'welcome-email',
                resourceType: Components\ResourceType::Layout,
                locale: 'en_US',
                content: [
                    'welcome.title' => 'Welcome',
                    'welcome.message' => 'Hello there!',
                ],
            );


            $response = $sdk->translations->create(
                createTranslationRequestDto: $createTranslationRequestDto
            );


            if ($response->translationResponseDto !== null) {
                // handle response
            }
        - lang: python
          label: Python
          source: |-
            import novu_py
            from novu_py import Novu


            with Novu(
                secret_key="YOUR_SECRET_KEY_HERE",
            ) as novu:

                res = novu.translations.create(create_translation_request_dto={
                    "resource_id": "welcome-email",
                    "resource_type": novu_py.ResourceType.LAYOUT,
                    "locale": "en_US",
                    "content": {
                        "welcome.title": "Welcome",
                        "welcome.message": "Hello there!",
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go
          source: "package main\n\nimport(\n\t\"context\"\n\t\"github.com/novuhq/novu-go/v3\"\n\t\"github.com/novuhq/novu-go/v3/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := v3.New(\n        v3.WithSecurity(\"YOUR_SECRET_KEY_HERE\"),\n    )\n\n    res, err := s.Translations.Create(ctx, components.CreateTranslationRequestDto{\n        ResourceID: \"welcome-email\",\n        ResourceType: components.ResourceTypeWorkflow,\n        Locale: \"en_US\",\n        Content: map[string]any{\n            \"welcome.title\": \"Welcome\",\n            \"welcome.message\": \"Hello there!\",\n        },\n    }, nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.TranslationResponseDto != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: TypeScript
          source: |-
            import { Novu } from "@novu/api";

            const novu = new Novu({
              secretKey: "YOUR_SECRET_KEY_HERE",
            });

            async function run() {
              const result = await novu.translations.create({
                resourceId: "welcome-email",
                resourceType: "workflow",
                locale: "en_US",
                content: {
                  "welcome.title": "Welcome",
                  "welcome.message": "Hello there!",
                },
              });

              console.log(result);
            }

            run();
        - lang: csharp
          label: Csharp (SDK)
          source: >-
            using Novu;

            using Novu.Models.Components;

            using System.Collections.Generic;


            var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");


            var res = await
            sdk.Translations.CreateAsync(createTranslationRequestDto: new
            CreateTranslationRequestDto() {
                ResourceId = "welcome-email",
                ResourceType = Novu.Models.Components.ResourceType.Workflow,
                Locale = "en_US",
                Content = new Dictionary<string, object>() {
                    { "welcome.title", "Welcome" },
                    { "welcome.message", "Hello there!" },
                },
            });


            // handle response
components:
  schemas:
    CreateTranslationRequestDto:
      type: object
      properties:
        resourceId:
          type: string
          description: >-
            The resource ID to associate translation with. Accepts identifier or
            slug format
          example: welcome-email
        resourceType:
          type: string
          description: The resource type to associate translation with
          enum:
            - workflow
            - layout
        locale:
          type: string
          description: Locale code (e.g., en_US, es_ES)
          example: en_US
        content:
          type: object
          description: Translation content as JSON object
          example:
            welcome.title: Welcome
            welcome.message: Hello there!
          additionalProperties: true
      required:
        - resourceId
        - resourceType
        - locale
        - content
    TranslationResponseDto:
      type: object
      properties:
        resourceId:
          type: string
          description: Resource identifier
          example: welcome-email
        resourceType:
          type: string
          description: Resource type
          example: workflow
          enum:
            - workflow
            - layout
        locale:
          type: string
          description: Locale code
          example: en_US
        content:
          type: object
          description: Translation content as JSON object
          example:
            welcome.title: Welcome
            welcome.message: Hello there!
          additionalProperties: true
        createdAt:
          type: string
          description: Creation timestamp
          example: '2024-01-01T00:00:00.000Z'
        updatedAt:
          type: string
          description: Last update timestamp
          example: '2024-01-01T00:00:00.000Z'
      required:
        - resourceId
        - resourceType
        - locale
        - content
        - createdAt
        - updatedAt
  securitySchemes:
    secretKey:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        API key authentication. Allowed headers-- "Authorization: ApiKey
        <novu_secret_key>".
      x-speakeasy-example: YOUR_SECRET_KEY_HERE

````