1. Packages
  2. Mailgun Provider
  3. API Docs
  4. ApiKey
Mailgun v3.6.1 published on Wednesday, Nov 5, 2025 by Pulumi

mailgun.ApiKey

Start a Neo task
Explain and create a mailgun.ApiKey resource
mailgun logo
Mailgun v3.6.1 published on Wednesday, Nov 5, 2025 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as mailgun from "@pulumi/mailgun";
    
    // Create a new Mailgun API key
    const someKey = new mailgun.ApiKey("some_key", {
        role: "basic",
        kind: "user",
        description: "Some key",
    });
    
    import pulumi
    import pulumi_mailgun as mailgun
    
    # Create a new Mailgun API key
    some_key = mailgun.ApiKey("some_key",
        role="basic",
        kind="user",
        description="Some key")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-mailgun/sdk/v3/go/mailgun"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a new Mailgun API key
    		_, err := mailgun.NewApiKey(ctx, "some_key", &mailgun.ApiKeyArgs{
    			Role:        pulumi.String("basic"),
    			Kind:        pulumi.String("user"),
    			Description: pulumi.String("Some key"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mailgun = Pulumi.Mailgun;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a new Mailgun API key
        var someKey = new Mailgun.ApiKey("some_key", new()
        {
            Role = "basic",
            Kind = "user",
            Description = "Some key",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mailgun.ApiKey;
    import com.pulumi.mailgun.ApiKeyArgs;
    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) {
            // Create a new Mailgun API key
            var someKey = new ApiKey("someKey", ApiKeyArgs.builder()
                .role("basic")
                .kind("user")
                .description("Some key")
                .build());
    
        }
    }
    
    resources:
      # Create a new Mailgun API key
      someKey:
        type: mailgun:ApiKey
        name: some_key
        properties:
          role: basic
          kind: user
          description: Some key
    

    Create ApiKey Resource

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

    Constructor syntax

    new ApiKey(name: string, args: ApiKeyArgs, opts?: CustomResourceOptions);
    @overload
    def ApiKey(resource_name: str,
               args: ApiKeyArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def ApiKey(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               role: Optional[str] = None,
               description: Optional[str] = None,
               domain_name: Optional[str] = None,
               email: Optional[str] = None,
               expires_at: Optional[int] = None,
               kind: Optional[str] = None,
               user_id: Optional[str] = None,
               user_name: Optional[str] = None)
    func NewApiKey(ctx *Context, name string, args ApiKeyArgs, opts ...ResourceOption) (*ApiKey, error)
    public ApiKey(string name, ApiKeyArgs args, CustomResourceOptions? opts = null)
    public ApiKey(String name, ApiKeyArgs args)
    public ApiKey(String name, ApiKeyArgs args, CustomResourceOptions options)
    
    type: mailgun:ApiKey
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ApiKeyArgs
    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 ApiKeyArgs
    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 ApiKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ApiKeyArgs
    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 apiKeyResource = new Mailgun.ApiKey("apiKeyResource", new()
    {
        Role = "string",
        Description = "string",
        DomainName = "string",
        Email = "string",
        ExpiresAt = 0,
        Kind = "string",
        UserId = "string",
        UserName = "string",
    });
    
    example, err := mailgun.NewApiKey(ctx, "apiKeyResource", &mailgun.ApiKeyArgs{
    	Role:        pulumi.String("string"),
    	Description: pulumi.String("string"),
    	DomainName:  pulumi.String("string"),
    	Email:       pulumi.String("string"),
    	ExpiresAt:   pulumi.Int(0),
    	Kind:        pulumi.String("string"),
    	UserId:      pulumi.String("string"),
    	UserName:    pulumi.String("string"),
    })
    
    var apiKeyResource = new ApiKey("apiKeyResource", ApiKeyArgs.builder()
        .role("string")
        .description("string")
        .domainName("string")
        .email("string")
        .expiresAt(0)
        .kind("string")
        .userId("string")
        .userName("string")
        .build());
    
    api_key_resource = mailgun.ApiKey("apiKeyResource",
        role="string",
        description="string",
        domain_name="string",
        email="string",
        expires_at=0,
        kind="string",
        user_id="string",
        user_name="string")
    
    const apiKeyResource = new mailgun.ApiKey("apiKeyResource", {
        role: "string",
        description: "string",
        domainName: "string",
        email: "string",
        expiresAt: 0,
        kind: "string",
        userId: "string",
        userName: "string",
    });
    
    type: mailgun:ApiKey
    properties:
        description: string
        domainName: string
        email: string
        expiresAt: 0
        kind: string
        role: string
        userId: string
        userName: string
    

    ApiKey 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 ApiKey resource accepts the following input properties:

    Role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    Description string
    Key description.
    DomainName string
    Web domain to associate with the key, for keys of domain kind.
    Email string
    API key user's email address; should be provided for all keys of web kind.
    ExpiresAt int
    When the key will expire.
    Kind string
    (Enum:domain, user, or web). API key type. Default: user.
    UserId string
    API key user's string user ID; should be provided for all keys of web kind.
    UserName string
    API key user's name.
    Role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    Description string
    Key description.
    DomainName string
    Web domain to associate with the key, for keys of domain kind.
    Email string
    API key user's email address; should be provided for all keys of web kind.
    ExpiresAt int
    When the key will expire.
    Kind string
    (Enum:domain, user, or web). API key type. Default: user.
    UserId string
    API key user's string user ID; should be provided for all keys of web kind.
    UserName string
    API key user's name.
    role String
    (Enum: admin, basic, sending, support, or developer) Key role.
    description String
    Key description.
    domainName String
    Web domain to associate with the key, for keys of domain kind.
    email String
    API key user's email address; should be provided for all keys of web kind.
    expiresAt Integer
    When the key will expire.
    kind String
    (Enum:domain, user, or web). API key type. Default: user.
    userId String
    API key user's string user ID; should be provided for all keys of web kind.
    userName String
    API key user's name.
    role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    description string
    Key description.
    domainName string
    Web domain to associate with the key, for keys of domain kind.
    email string
    API key user's email address; should be provided for all keys of web kind.
    expiresAt number
    When the key will expire.
    kind string
    (Enum:domain, user, or web). API key type. Default: user.
    userId string
    API key user's string user ID; should be provided for all keys of web kind.
    userName string
    API key user's name.
    role str
    (Enum: admin, basic, sending, support, or developer) Key role.
    description str
    Key description.
    domain_name str
    Web domain to associate with the key, for keys of domain kind.
    email str
    API key user's email address; should be provided for all keys of web kind.
    expires_at int
    When the key will expire.
    kind str
    (Enum:domain, user, or web). API key type. Default: user.
    user_id str
    API key user's string user ID; should be provided for all keys of web kind.
    user_name str
    API key user's name.
    role String
    (Enum: admin, basic, sending, support, or developer) Key role.
    description String
    Key description.
    domainName String
    Web domain to associate with the key, for keys of domain kind.
    email String
    API key user's email address; should be provided for all keys of web kind.
    expiresAt Number
    When the key will expire.
    kind String
    (Enum:domain, user, or web). API key type. Default: user.
    userId String
    API key user's string user ID; should be provided for all keys of web kind.
    userName String
    API key user's name.

    Outputs

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

    DisabledReason string
    The reason for the key's disablement.
    Id string
    The provider-assigned unique ID for this managed resource.
    IsDisabled bool
    Whether or not the key is disabled from use.
    Requestor string
    An email address associated with the key.
    Secret string
    The full API key secret in plain text.
    DisabledReason string
    The reason for the key's disablement.
    Id string
    The provider-assigned unique ID for this managed resource.
    IsDisabled bool
    Whether or not the key is disabled from use.
    Requestor string
    An email address associated with the key.
    Secret string
    The full API key secret in plain text.
    disabledReason String
    The reason for the key's disablement.
    id String
    The provider-assigned unique ID for this managed resource.
    isDisabled Boolean
    Whether or not the key is disabled from use.
    requestor String
    An email address associated with the key.
    secret String
    The full API key secret in plain text.
    disabledReason string
    The reason for the key's disablement.
    id string
    The provider-assigned unique ID for this managed resource.
    isDisabled boolean
    Whether or not the key is disabled from use.
    requestor string
    An email address associated with the key.
    secret string
    The full API key secret in plain text.
    disabled_reason str
    The reason for the key's disablement.
    id str
    The provider-assigned unique ID for this managed resource.
    is_disabled bool
    Whether or not the key is disabled from use.
    requestor str
    An email address associated with the key.
    secret str
    The full API key secret in plain text.
    disabledReason String
    The reason for the key's disablement.
    id String
    The provider-assigned unique ID for this managed resource.
    isDisabled Boolean
    Whether or not the key is disabled from use.
    requestor String
    An email address associated with the key.
    secret String
    The full API key secret in plain text.

    Look up Existing ApiKey Resource

    Get an existing ApiKey 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?: ApiKeyState, opts?: CustomResourceOptions): ApiKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            disabled_reason: Optional[str] = None,
            domain_name: Optional[str] = None,
            email: Optional[str] = None,
            expires_at: Optional[int] = None,
            is_disabled: Optional[bool] = None,
            kind: Optional[str] = None,
            requestor: Optional[str] = None,
            role: Optional[str] = None,
            secret: Optional[str] = None,
            user_id: Optional[str] = None,
            user_name: Optional[str] = None) -> ApiKey
    func GetApiKey(ctx *Context, name string, id IDInput, state *ApiKeyState, opts ...ResourceOption) (*ApiKey, error)
    public static ApiKey Get(string name, Input<string> id, ApiKeyState? state, CustomResourceOptions? opts = null)
    public static ApiKey get(String name, Output<String> id, ApiKeyState state, CustomResourceOptions options)
    resources:  _:    type: mailgun:ApiKey    get:      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:
    Description string
    Key description.
    DisabledReason string
    The reason for the key's disablement.
    DomainName string
    Web domain to associate with the key, for keys of domain kind.
    Email string
    API key user's email address; should be provided for all keys of web kind.
    ExpiresAt int
    When the key will expire.
    IsDisabled bool
    Whether or not the key is disabled from use.
    Kind string
    (Enum:domain, user, or web). API key type. Default: user.
    Requestor string
    An email address associated with the key.
    Role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    Secret string
    The full API key secret in plain text.
    UserId string
    API key user's string user ID; should be provided for all keys of web kind.
    UserName string
    API key user's name.
    Description string
    Key description.
    DisabledReason string
    The reason for the key's disablement.
    DomainName string
    Web domain to associate with the key, for keys of domain kind.
    Email string
    API key user's email address; should be provided for all keys of web kind.
    ExpiresAt int
    When the key will expire.
    IsDisabled bool
    Whether or not the key is disabled from use.
    Kind string
    (Enum:domain, user, or web). API key type. Default: user.
    Requestor string
    An email address associated with the key.
    Role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    Secret string
    The full API key secret in plain text.
    UserId string
    API key user's string user ID; should be provided for all keys of web kind.
    UserName string
    API key user's name.
    description String
    Key description.
    disabledReason String
    The reason for the key's disablement.
    domainName String
    Web domain to associate with the key, for keys of domain kind.
    email String
    API key user's email address; should be provided for all keys of web kind.
    expiresAt Integer
    When the key will expire.
    isDisabled Boolean
    Whether or not the key is disabled from use.
    kind String
    (Enum:domain, user, or web). API key type. Default: user.
    requestor String
    An email address associated with the key.
    role String
    (Enum: admin, basic, sending, support, or developer) Key role.
    secret String
    The full API key secret in plain text.
    userId String
    API key user's string user ID; should be provided for all keys of web kind.
    userName String
    API key user's name.
    description string
    Key description.
    disabledReason string
    The reason for the key's disablement.
    domainName string
    Web domain to associate with the key, for keys of domain kind.
    email string
    API key user's email address; should be provided for all keys of web kind.
    expiresAt number
    When the key will expire.
    isDisabled boolean
    Whether or not the key is disabled from use.
    kind string
    (Enum:domain, user, or web). API key type. Default: user.
    requestor string
    An email address associated with the key.
    role string
    (Enum: admin, basic, sending, support, or developer) Key role.
    secret string
    The full API key secret in plain text.
    userId string
    API key user's string user ID; should be provided for all keys of web kind.
    userName string
    API key user's name.
    description str
    Key description.
    disabled_reason str
    The reason for the key's disablement.
    domain_name str
    Web domain to associate with the key, for keys of domain kind.
    email str
    API key user's email address; should be provided for all keys of web kind.
    expires_at int
    When the key will expire.
    is_disabled bool
    Whether or not the key is disabled from use.
    kind str
    (Enum:domain, user, or web). API key type. Default: user.
    requestor str
    An email address associated with the key.
    role str
    (Enum: admin, basic, sending, support, or developer) Key role.
    secret str
    The full API key secret in plain text.
    user_id str
    API key user's string user ID; should be provided for all keys of web kind.
    user_name str
    API key user's name.
    description String
    Key description.
    disabledReason String
    The reason for the key's disablement.
    domainName String
    Web domain to associate with the key, for keys of domain kind.
    email String
    API key user's email address; should be provided for all keys of web kind.
    expiresAt Number
    When the key will expire.
    isDisabled Boolean
    Whether or not the key is disabled from use.
    kind String
    (Enum:domain, user, or web). API key type. Default: user.
    requestor String
    An email address associated with the key.
    role String
    (Enum: admin, basic, sending, support, or developer) Key role.
    secret String
    The full API key secret in plain text.
    userId String
    API key user's string user ID; should be provided for all keys of web kind.
    userName String
    API key user's name.

    Package Details

    Repository
    Mailgun pulumi/pulumi-mailgun
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mailgun Terraform Provider.
    mailgun logo
    Mailgun v3.6.1 published on Wednesday, Nov 5, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate