Documentation Index
Fetch the complete documentation index at: https://www.1password.dev/llms.txt
Use this file to discover all available pages before exploring further.
You can use 1Password SDKs to securely share a copy of a 1Password item with anyone, even if they don’t have a 1Password account.
When you share an item, you’ll get a unique link that you can send to others. You can choose when the link expires and who it’s available to: anyone with the link, or only people with specific email addresses or email domains. You can also choose whether you want the link to be viewable only once, or multiple times.
Before you get started
Before you begin, follow the steps to get started with a 1Password SDK. The examples on this page assume you have an initialized client instance. For example:
package main
import (
"context"
"github.com/1password/onepassword-sdk-go"
)
func main() {
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client, err := onepassword.NewClient(context.Background(),
)
if err != nil {
panic(err)
}
// Your code here
}
import sdk from "@1password/sdk";
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
const sdk = require("@1password/sdk");
async function main() {
const client = await sdk.createClient({
// TODO: Initialize client using your preferred authentication method (see Overview > Get started)
});
// Your code here
}
main().catch(console.error);
import asyncio
from onepassword import Client # Also import DesktopAuth for desktop app authentication.
async def main():
# TODO: Initialize client using your preferred authentication method (see Overview > Get started)
client = await Client.authenticate(...)
# Your code here
asyncio.run(main())
See the examples folder in the 1Password Go, JavaScript, or Python SDK GitHub repository for full example code you can quickly clone and test in your project.
Make sure to add the Share items permission when creating a service account token to share items using the SDKs.
Step 1: Retrieve the 1Password item you want to share
To retrieve the item you want to share, use the Items().Get() method with the unique identifiers (IDs) for the item and the vault where the item is stored.item, err := client.Items().Get(context.Background(), vaultID, itemID)
if err != nil {
panic(err)
}
To retrieve the item you want to share, use the items.get() method with the unique identifiers (IDs) for the item and the vault where the item is stored.let item = await client.items.get(vaultId, itemId);
console.log(item);
To retrieve the item you want to share, use the items.get() method with the unique identifiers (IDs) for the item and the vault where the item is stored.from onepassword import ItemShareDuration, ItemShareParams
# Get an item to share
item = await client.items.get("your-vault-id", "your-item-id")
print(item)
Step 2: Fetch the item sharing account policy
The item sharing account policy contains the allowed share settings that your account admin or owner has set.
For individual and family accounts, these settings default to:
- Unlimited views
- All recipient types allowed
- All share types allowed
- Maximum share duration of 30 days
- Default share duration of 7 days
To fetch the item sharing account policy, use the Items().Shares().GetAccountPolicy() method with the unique identifiers (IDs) for the item and the vault where the item is stored.accountPolicy, err := client.Items().Shares().GetAccountPolicy(context.Background(), item.VaultID, item.ID)
if err != nil {
panic(err)
}
To fetch the item sharing account policy, use the items.shares.getAccountPolicy() method with the unique identifiers (IDs) for the item and the vault where the item is stored.let policy = await client.items.shares.getAccountPolicy(
item.vaultId,
item.id,
);
console.log(policy);
To fetch the item sharing account policy, use the items.shares.get_account_policy() method with the unique identifiers (IDs) for the item and the vault where the item is stored.from onepassword import ItemShareDuration, ItemShareParams
# Get your item sharing account policy
policy = await client.items.shares.get_account_policy(item.vault_id, item.id)
print(policy)
Step 3: (Optional) Validate the recipients
You can validate recipients to make sure that the people you want to share the link with are allowed to receive it, based on your account policy or sharing parameters.
This step is only required if the item sharing link is limited to specific email addresses or domains. If the share link is accessible to anyone with the link, you can skip validating the recipients.
To validate the recipients, use the Items().Shares().ValidateRecipients() method. Replace helloworld@agilebits.com with the recipient’s email address or domain in the example below.recipients, err := client.Items().Shares().ValidateRecipients(context.Background(), accountPolicy, []string{"helloworld@agilebits.com"})
if err != nil {
panic(err)
}
To validate the recipients, use the items.shares.validateRecipients() method. Replace helloworld@agilebits.com with the recipient’s email address or domain in the example below.let valid_recipients = await client.items.shares.validateRecipients(policy, [
"helloworld@agilebits.com",
]);
console.log(valid_recipients);
To validate the recipients, use the items.shares.validate_recipients() method. Replace helloworld@agilebits.com with the recipient’s email address or domain in the example below.from onepassword import ItemShareDuration, ItemShareParams
# Validate item share recipients
valid_recipients = await client.items.shares.validate_recipients(
policy, ["your-recipient-email-address"]
)
print(valid_recipients)
Step 4: Create the item sharing link
Use the Items().Shares().Create() method to create a unique link you can send to others. This method requires an ItemShareParams struct with the following fields:
ExpireAfter: How long the item link will remain accessible. Options include: OneHour, OneDay, SevenDays, FourteenDays, ThirtyDays. Not specifying this will default to the DefaultShareDuration in the account policy.
Recipients: The validated recipients of an item share, obtained through the recipient validation function. Leaving this parameter empty will allow everyone with the link to see the item.
OneTimeOnly: A boolean that determines if the link expires after one view.
The SDK will create the link based on the configuration settings in the ItemShareParams struct. If you have a 1Password Business account, it will also validate the settings against the item sharing policy set by your account owner or administrator.The SDK returns a shareLink you can send to the person or people you want to share the item with.shareLink, err := client.Items().Shares().Create(context.Background(), item, accountPolicy, onepassword.ItemShareParams{
Recipients: recipients,
ExpireAfter: &accountPolicy.DefaultExpiry,
OneTimeOnly: false,
})
if err != nil {
panic(err)
}
Use the items.shares.create() method to create a unique link you can send to others. This method requires an ItemShareParams object with the following properties:
expireAfter: How long the link will remain accessible. Options include: OneHour, OneDay, SevenDays, FourteenDays, ThirtyDays. Not specifying this will default to the DefaultShareDuration in the account policy.
recipients: An array of ValidRecipient objects. Leave empty to allow anyone with the link to view the shared item.
oneTimeOnly: A boolean that determines if the link expires after a single view.
The SDK will create the link based on the configuration settings in the ItemShareParams object. If you have a 1Password Business account, it will also validate the settings against the item sharing policy set by your account owner or administrator.The SDK returns a share_link you can send to the person or people you want to share the item with.let share_link = await client.items.shares.create(item, policy, {
expireAfter: sdk.ItemShareDuration.OneHour,
oneTimeOnly: false,
recipients: valid_recipients,
});
console.log(share_link);
Use the items.shares.create() method to create a unique link you can send to others. This method requires an ItemShareParams object with the following attributes:
expire_after: How long the item share link will remain accessible. Options include: OneHour, OneDay, SevenDays, FourteenDays, ThirtyDays. Not specifying this will default to the DefaultShareDuration in the account policy.
recipients: An array of ValidRecipient objects. Leave empty to allow anyone with the link to view the shared item.
one_time_only: A boolean that determines if the link expires after a single view.
The SDK will create your item share link based on the configuration settings in the ItemShareParams object. If you have a 1Password Business account, it will also validate the settings against the item sharing policy set by your account owner or administrator.The SDK returns a share_link you can send to the person or people you want to share the item with.from onepassword import ItemShareDuration, ItemShareParams
# Create a unique link to share the item
share_link = await client.items.shares.create(
item,
policy,
ItemShareParams(
recipients=valid_recipients,
expireAfter=ItemShareDuration.ONEHOUR,
oneTimeOnly=False,
),
)
print(share_link)