Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Share Email

POST

/

emails

/

:email_id

/

share

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.emails.share(
  '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794',
  { expiresIn: '2 hours' },
);
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->emails->share('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', [
  'expires_in' => '2 hours'
]);
Python
import resend

resend.api_key = "re_xxxxxxxxx"

share_params: resend.Emails.ShareParams = {
  "expires_in": "2 hours"
}

resend.Emails.share(
  email_id="49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  params=share_params
)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

Resend::Emails.share(
  "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  expires_in: "2 hours"
)
Go
package main

import (
	"fmt"

	"github.com/resend/resend-go/v4"
)

func main() {
	client := resend.NewClient("re_xxxxxxxxx")

	shareParams := &resend.ShareEmailRequest{
		ExpiresIn: "2 hours",
	}

	shared, err := client.Emails.Share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", shareParams)
	if err != nil {
		panic(err)
	}
	fmt.Println(shared.Url)
}
Rust
use resend_rs::types::ShareEmailOptions;
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let share = ShareEmailOptions::new()
    .with_expires_in("2 hours");

  let _shared = resend
    .emails
    .share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", share)
    .await?;

  Ok(())
}
Java
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.emails.model.ShareEmailOptions;
import com.resend.services.emails.model.ShareEmailResponse;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        ShareEmailOptions shareParams = ShareEmailOptions.builder()
                .expiresIn("2 hours")
                .build();

        ShareEmailResponse data = resend
          .emails()
          .share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", shareParams);
    }
}
.NET
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

await resend.EmailShareAsync(
    new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ),
    "2 hours" );
cURL
curl -X POST 'https://api.resend.com/emails/49a3999c-0ce1-4ea6-ab68-afcd6dc2e794/share' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "expires_in": "2 hours"
}'
CLI
resend emails share 49a3999c-0ce1-4ea6-ab68-afcd6dc2e794 \
  --expires-in "2 hours"
Response
{
  "object": "email",
  "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  "url": "https://resend.com/shared?token=eyJhbGciOiJIUzI1NiJ9..."
}
Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.emails.share(
  '49a3999c-0ce1-4ea6-ab68-afcd6dc2e794',
  { expiresIn: '2 hours' },
);
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->emails->share('49a3999c-0ce1-4ea6-ab68-afcd6dc2e794', [
  'expires_in' => '2 hours'
]);
Python
import resend

resend.api_key = "re_xxxxxxxxx"

share_params: resend.Emails.ShareParams = {
  "expires_in": "2 hours"
}

resend.Emails.share(
  email_id="49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  params=share_params
)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

Resend::Emails.share(
  "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  expires_in: "2 hours"
)
Go
package main

import (
	"fmt"

	"github.com/resend/resend-go/v4"
)

func main() {
	client := resend.NewClient("re_xxxxxxxxx")

	shareParams := &resend.ShareEmailRequest{
		ExpiresIn: "2 hours",
	}

	shared, err := client.Emails.Share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", shareParams)
	if err != nil {
		panic(err)
	}
	fmt.Println(shared.Url)
}
Rust
use resend_rs::types::ShareEmailOptions;
use resend_rs::{Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let share = ShareEmailOptions::new()
    .with_expires_in("2 hours");

  let _shared = resend
    .emails
    .share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", share)
    .await?;

  Ok(())
}
Java
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.emails.model.ShareEmailOptions;
import com.resend.services.emails.model.ShareEmailResponse;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        ShareEmailOptions shareParams = ShareEmailOptions.builder()
                .expiresIn("2 hours")
                .build();

        ShareEmailResponse data = resend
          .emails()
          .share("49a3999c-0ce1-4ea6-ab68-afcd6dc2e794", shareParams);
    }
}
.NET
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

await resend.EmailShareAsync(
    new Guid( "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" ),
    "2 hours" );
cURL
curl -X POST 'https://api.resend.com/emails/49a3999c-0ce1-4ea6-ab68-afcd6dc2e794/share' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "expires_in": "2 hours"
}'
CLI
resend emails share 49a3999c-0ce1-4ea6-ab68-afcd6dc2e794 \
  --expires-in "2 hours"
JSON
{
  "object": "email",
  "id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794",
  "url": "https://resend.com/shared?token=eyJhbGciOiJIUzI1NiJ9..."
}

Was this page helpful?

⌘I

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu