1. Registry
  2. Packages
  3. Netbox Provider
  4. API Docs
  5. ExportTemplate
Viewing docs for netbox 6.0.0
published on Wednesday, Nov 4, 2026 by e-breuninger
netbox
Viewing docs for netbox 6.0.0
published on Wednesday, Nov 4, 2026 by e-breuninger

    A Jinja2 export template for the object types it applies to (extras.exporttemplate).

    From the official documentation:

    Export templates are used to render arbitrary data from a set of NetBox objects. For example, you might want to automatically generate a network monitoring service configuration from a list of device objects. See the export templates documentation for more information.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as netbox from "@pulumi/netbox";
    
    const test = new netbox.ExportTemplate("test", {
        name: "test-export-template",
        objectTypes: ["dcim.device"],
        templateCode: `{% for obj in queryset %}{{ obj.name }}
    {% endfor %}`,
        mimeType: "text/csv",
        fileName: "test-file",
        fileExtension: "csv",
        asAttachment: true,
        description: "test-description",
    });
    
    import pulumi
    import pulumi_netbox as netbox
    
    test = netbox.ExportTemplate("test",
        name="test-export-template",
        object_types=["dcim.device"],
        template_code="""{% for obj in queryset %}{{ obj.name }}
    {% endfor %}""",
        mime_type="text/csv",
        file_name="test-file",
        file_extension="csv",
        as_attachment=True,
        description="test-description")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/netbox/v6/netbox"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := netbox.NewExportTemplate(ctx, "test", &netbox.ExportTemplateArgs{
    			Name: pulumi.String("test-export-template"),
    			ObjectTypes: pulumi.StringArray{
    				pulumi.String("dcim.device"),
    			},
    			TemplateCode:  pulumi.String("{% for obj in queryset %}{{ obj.name }}\n{% endfor %}"),
    			MimeType:      pulumi.String("text/csv"),
    			FileName:      pulumi.String("test-file"),
    			FileExtension: pulumi.String("csv"),
    			AsAttachment:  pulumi.Bool(true),
    			Description:   pulumi.String("test-description"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Netbox = Pulumi.Netbox;
    
    return await Deployment.RunAsync(() => 
    {
        var test = new Netbox.ExportTemplate("test", new()
        {
            Name = "test-export-template",
            ObjectTypes = new[]
            {
                "dcim.device",
            },
            TemplateCode = @"{% for obj in queryset %}{{ obj.name }}
    {% endfor %}",
            MimeType = "text/csv",
            FileName = "test-file",
            FileExtension = "csv",
            AsAttachment = true,
            Description = "test-description",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.netbox.ExportTemplate;
    import com.pulumi.netbox.ExportTemplateArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var test = new ExportTemplate("test", ExportTemplateArgs.builder()
                .name("test-export-template")
                .objectTypes("dcim.device")
                .templateCode("""
    {% for obj in queryset %}{{ obj.name }}
    {% endfor %}            """)
                .mimeType("text/csv")
                .fileName("test-file")
                .fileExtension("csv")
                .asAttachment(true)
                .description("test-description")
                .build());
    
        }
    }
    
    resources:
      test:
        type: netbox:ExportTemplate
        properties:
          name: test-export-template
          objectTypes:
            - dcim.device
          templateCode: |-
            {% for obj in queryset %}{{ obj.name }}
            {% endfor %}
          mimeType: text/csv
          fileName: test-file
          fileExtension: csv
          asAttachment: true
          description: test-description
    
    Example coming soon!
    

    Create ExportTemplate Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ExportTemplate(name: string, args: ExportTemplateArgs, opts?: CustomResourceOptions);
    @overload
    def ExportTemplate(resource_name: str,
                       args: ExportTemplateArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def ExportTemplate(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       object_types: Optional[Sequence[str]] = None,
                       template_code: Optional[str] = None,
                       as_attachment: Optional[bool] = None,
                       description: Optional[str] = None,
                       environment_params: Optional[str] = None,
                       file_extension: Optional[str] = None,
                       file_name: Optional[str] = None,
                       mime_type: Optional[str] = None,
                       name: Optional[str] = None,
                       owner_id: Optional[float] = None)
    func NewExportTemplate(ctx *Context, name string, args ExportTemplateArgs, opts ...ResourceOption) (*ExportTemplate, error)
    public ExportTemplate(string name, ExportTemplateArgs args, CustomResourceOptions? opts = null)
    public ExportTemplate(String name, ExportTemplateArgs args)
    public ExportTemplate(String name, ExportTemplateArgs args, CustomResourceOptions options)
    
    type: netbox:ExportTemplate
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "netbox_export_template" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ExportTemplateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ExportTemplateArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ExportTemplateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ExportTemplateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ExportTemplateArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var exportTemplateResource = new Netbox.ExportTemplate("exportTemplateResource", new()
    {
        ObjectTypes = new[]
        {
            "string",
        },
        TemplateCode = "string",
        AsAttachment = false,
        Description = "string",
        EnvironmentParams = "string",
        FileExtension = "string",
        FileName = "string",
        MimeType = "string",
        Name = "string",
        OwnerId = 0.0,
    });
    
    example, err := netbox.NewExportTemplate(ctx, "exportTemplateResource", &netbox.ExportTemplateArgs{
    	ObjectTypes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	TemplateCode:      pulumi.String("string"),
    	AsAttachment:      pulumi.Bool(false),
    	Description:       pulumi.String("string"),
    	EnvironmentParams: pulumi.String("string"),
    	FileExtension:     pulumi.String("string"),
    	FileName:          pulumi.String("string"),
    	MimeType:          pulumi.String("string"),
    	Name:              pulumi.String("string"),
    	OwnerId:           pulumi.Float64(0),
    })
    
    resource "netbox_export_template" "exportTemplateResource" {
      lifecycle {
        create_before_destroy = true
      }
      object_types       = ["string"]
      template_code      = "string"
      as_attachment      = false
      description        = "string"
      environment_params = "string"
      file_extension     = "string"
      file_name          = "string"
      mime_type          = "string"
      name               = "string"
      owner_id           = 0
    }
    
    var exportTemplateResource = new ExportTemplate("exportTemplateResource", ExportTemplateArgs.builder()
        .objectTypes("string")
        .templateCode("string")
        .asAttachment(false)
        .description("string")
        .environmentParams("string")
        .fileExtension("string")
        .fileName("string")
        .mimeType("string")
        .name("string")
        .ownerId(0.0)
        .build());
    
    export_template_resource = netbox.ExportTemplate("exportTemplateResource",
        object_types=["string"],
        template_code="string",
        as_attachment=False,
        description="string",
        environment_params="string",
        file_extension="string",
        file_name="string",
        mime_type="string",
        name="string",
        owner_id=float(0))
    
    const exportTemplateResource = new netbox.ExportTemplate("exportTemplateResource", {
        objectTypes: ["string"],
        templateCode: "string",
        asAttachment: false,
        description: "string",
        environmentParams: "string",
        fileExtension: "string",
        fileName: "string",
        mimeType: "string",
        name: "string",
        ownerId: 0,
    });
    
    type: netbox:ExportTemplate
    properties:
        asAttachment: false
        description: string
        environmentParams: string
        fileExtension: string
        fileName: string
        mimeType: string
        name: string
        objectTypes:
            - string
        ownerId: 0
        templateCode: string
    

    ExportTemplate Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ExportTemplate resource accepts the following input properties:

    ObjectTypes List<string>
    Object types the template can export, as app-labelled content types (dcim.device).
    TemplateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    AsAttachment bool
    Download the rendered output as a file instead of displaying it.
    Description string
    EnvironmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    FileExtension string
    Extension appended to the file name, e.g. csv.
    FileName string
    File name of the rendered output, without extension.
    MimeType string
    MIME type of the rendered output, e.g. text/csv.
    Name string
    OwnerId double
    Id of the owner the object is assigned to.
    ObjectTypes []string
    Object types the template can export, as app-labelled content types (dcim.device).
    TemplateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    AsAttachment bool
    Download the rendered output as a file instead of displaying it.
    Description string
    EnvironmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    FileExtension string
    Extension appended to the file name, e.g. csv.
    FileName string
    File name of the rendered output, without extension.
    MimeType string
    MIME type of the rendered output, e.g. text/csv.
    Name string
    OwnerId float64
    Id of the owner the object is assigned to.
    object_types list(string)
    Object types the template can export, as app-labelled content types (dcim.device).
    template_code string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    as_attachment bool
    Download the rendered output as a file instead of displaying it.
    description string
    environment_params string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    file_extension string
    Extension appended to the file name, e.g. csv.
    file_name string
    File name of the rendered output, without extension.
    mime_type string
    MIME type of the rendered output, e.g. text/csv.
    name string
    owner_id number
    Id of the owner the object is assigned to.
    objectTypes List<String>
    Object types the template can export, as app-labelled content types (dcim.device).
    templateCode String
    Jinja2 template code; the queryset is available as {{ queryset }}.
    asAttachment Boolean
    Download the rendered output as a file instead of displaying it.
    description String
    environmentParams String
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    fileExtension String
    Extension appended to the file name, e.g. csv.
    fileName String
    File name of the rendered output, without extension.
    mimeType String
    MIME type of the rendered output, e.g. text/csv.
    name String
    ownerId Double
    Id of the owner the object is assigned to.
    objectTypes string[]
    Object types the template can export, as app-labelled content types (dcim.device).
    templateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    asAttachment boolean
    Download the rendered output as a file instead of displaying it.
    description string
    environmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    fileExtension string
    Extension appended to the file name, e.g. csv.
    fileName string
    File name of the rendered output, without extension.
    mimeType string
    MIME type of the rendered output, e.g. text/csv.
    name string
    ownerId number
    Id of the owner the object is assigned to.
    object_types Sequence[str]
    Object types the template can export, as app-labelled content types (dcim.device).
    template_code str
    Jinja2 template code; the queryset is available as {{ queryset }}.
    as_attachment bool
    Download the rendered output as a file instead of displaying it.
    description str
    environment_params str
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    file_extension str
    Extension appended to the file name, e.g. csv.
    file_name str
    File name of the rendered output, without extension.
    mime_type str
    MIME type of the rendered output, e.g. text/csv.
    name str
    owner_id float
    Id of the owner the object is assigned to.
    objectTypes List<String>
    Object types the template can export, as app-labelled content types (dcim.device).
    templateCode String
    Jinja2 template code; the queryset is available as {{ queryset }}.
    asAttachment Boolean
    Download the rendered output as a file instead of displaying it.
    description String
    environmentParams String
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    fileExtension String
    Extension appended to the file name, e.g. csv.
    fileName String
    File name of the rendered output, without extension.
    mimeType String
    MIME type of the rendered output, e.g. text/csv.
    name String
    ownerId Number
    Id of the owner the object is assigned to.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ExportTemplate resource produces the following output properties:

    Created string
    ExportTemplateId double
    NetBox id.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdated string
    Url string
    Created string
    ExportTemplateId float64
    NetBox id.
    Id string
    The provider-assigned unique ID for this managed resource.
    LastUpdated string
    Url string
    created string
    export_template_id number
    NetBox id.
    id string
    The provider-assigned unique ID for this managed resource.
    last_updated string
    url string
    created String
    exportTemplateId Double
    NetBox id.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdated String
    url String
    created string
    exportTemplateId number
    NetBox id.
    id string
    The provider-assigned unique ID for this managed resource.
    lastUpdated string
    url string
    created str
    export_template_id float
    NetBox id.
    id str
    The provider-assigned unique ID for this managed resource.
    last_updated str
    url str
    created String
    exportTemplateId Number
    NetBox id.
    id String
    The provider-assigned unique ID for this managed resource.
    lastUpdated String
    url String

    Look up Existing ExportTemplate Resource

    Get an existing ExportTemplate resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ExportTemplateState, opts?: CustomResourceOptions): ExportTemplate
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            as_attachment: Optional[bool] = None,
            created: Optional[str] = None,
            description: Optional[str] = None,
            environment_params: Optional[str] = None,
            export_template_id: Optional[float] = None,
            file_extension: Optional[str] = None,
            file_name: Optional[str] = None,
            last_updated: Optional[str] = None,
            mime_type: Optional[str] = None,
            name: Optional[str] = None,
            object_types: Optional[Sequence[str]] = None,
            owner_id: Optional[float] = None,
            template_code: Optional[str] = None,
            url: Optional[str] = None) -> ExportTemplate
    func GetExportTemplate(ctx *Context, name string, id IDInput, state *ExportTemplateState, opts ...ResourceOption) (*ExportTemplate, error)
    public static ExportTemplate Get(string name, Input<string> id, ExportTemplateState? state, CustomResourceOptions? opts = null)
    public static ExportTemplate get(String name, Output<String> id, ExportTemplateState state, CustomResourceOptions options)
    resources:  _:    type: netbox:ExportTemplate    get:      id: ${id}
    import {
      to = netbox_export_template.example
      id = "${id}"
    }
    
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AsAttachment bool
    Download the rendered output as a file instead of displaying it.
    Created string
    Description string
    EnvironmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    ExportTemplateId double
    NetBox id.
    FileExtension string
    Extension appended to the file name, e.g. csv.
    FileName string
    File name of the rendered output, without extension.
    LastUpdated string
    MimeType string
    MIME type of the rendered output, e.g. text/csv.
    Name string
    ObjectTypes List<string>
    Object types the template can export, as app-labelled content types (dcim.device).
    OwnerId double
    Id of the owner the object is assigned to.
    TemplateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    Url string
    AsAttachment bool
    Download the rendered output as a file instead of displaying it.
    Created string
    Description string
    EnvironmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    ExportTemplateId float64
    NetBox id.
    FileExtension string
    Extension appended to the file name, e.g. csv.
    FileName string
    File name of the rendered output, without extension.
    LastUpdated string
    MimeType string
    MIME type of the rendered output, e.g. text/csv.
    Name string
    ObjectTypes []string
    Object types the template can export, as app-labelled content types (dcim.device).
    OwnerId float64
    Id of the owner the object is assigned to.
    TemplateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    Url string
    as_attachment bool
    Download the rendered output as a file instead of displaying it.
    created string
    description string
    environment_params string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    export_template_id number
    NetBox id.
    file_extension string
    Extension appended to the file name, e.g. csv.
    file_name string
    File name of the rendered output, without extension.
    last_updated string
    mime_type string
    MIME type of the rendered output, e.g. text/csv.
    name string
    object_types list(string)
    Object types the template can export, as app-labelled content types (dcim.device).
    owner_id number
    Id of the owner the object is assigned to.
    template_code string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    url string
    asAttachment Boolean
    Download the rendered output as a file instead of displaying it.
    created String
    description String
    environmentParams String
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    exportTemplateId Double
    NetBox id.
    fileExtension String
    Extension appended to the file name, e.g. csv.
    fileName String
    File name of the rendered output, without extension.
    lastUpdated String
    mimeType String
    MIME type of the rendered output, e.g. text/csv.
    name String
    objectTypes List<String>
    Object types the template can export, as app-labelled content types (dcim.device).
    ownerId Double
    Id of the owner the object is assigned to.
    templateCode String
    Jinja2 template code; the queryset is available as {{ queryset }}.
    url String
    asAttachment boolean
    Download the rendered output as a file instead of displaying it.
    created string
    description string
    environmentParams string
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    exportTemplateId number
    NetBox id.
    fileExtension string
    Extension appended to the file name, e.g. csv.
    fileName string
    File name of the rendered output, without extension.
    lastUpdated string
    mimeType string
    MIME type of the rendered output, e.g. text/csv.
    name string
    objectTypes string[]
    Object types the template can export, as app-labelled content types (dcim.device).
    ownerId number
    Id of the owner the object is assigned to.
    templateCode string
    Jinja2 template code; the queryset is available as {{ queryset }}.
    url string
    as_attachment bool
    Download the rendered output as a file instead of displaying it.
    created str
    description str
    environment_params str
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    export_template_id float
    NetBox id.
    file_extension str
    Extension appended to the file name, e.g. csv.
    file_name str
    File name of the rendered output, without extension.
    last_updated str
    mime_type str
    MIME type of the rendered output, e.g. text/csv.
    name str
    object_types Sequence[str]
    Object types the template can export, as app-labelled content types (dcim.device).
    owner_id float
    Id of the owner the object is assigned to.
    template_code str
    Jinja2 template code; the queryset is available as {{ queryset }}.
    url str
    asAttachment Boolean
    Download the rendered output as a file instead of displaying it.
    created String
    description String
    environmentParams String
    Parameters for the Jinja2 environment as JSON text (use jsonencode()).
    exportTemplateId Number
    NetBox id.
    fileExtension String
    Extension appended to the file name, e.g. csv.
    fileName String
    File name of the rendered output, without extension.
    lastUpdated String
    mimeType String
    MIME type of the rendered output, e.g. text/csv.
    name String
    objectTypes List<String>
    Object types the template can export, as app-labelled content types (dcim.device).
    ownerId Number
    Id of the owner the object is assigned to.
    templateCode String
    Jinja2 template code; the queryset is available as {{ queryset }}.
    url String

    Import

    In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

    terraform

    import {

    to = netbox_export_template.test

    id = “123”

    }

    The pulumi import command can be used, for example:

    $ pulumi import netbox:index/exportTemplate:ExportTemplate test 123
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    netbox e-breuninger/terraform-provider-netbox
    License
    Notes
    This Pulumi package is based on the netbox Terraform Provider.
    netbox
    Viewing docs for netbox 6.0.0
    published on Wednesday, Nov 4, 2026 by e-breuninger

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial