惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
量子位
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
V
Visual Studio Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
V
V2EX
The GitHub Blog
The GitHub Blog
博客园_首页
月光博客
月光博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
博客园 - 叶小钗
F
Fortinet All Blogs
T
Tailwind CSS Blog
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
WordPress大学
WordPress大学
B
Blog
H
Help Net Security

Netlify Developers

AI model comparison using Netlify's AI Gateway | Netlify Developers Build an AI agent to automatically process and summarize form submissions | Netlify Developers Build an AI agent to automatically generate relevant images for blog posts | Netlify Developers Prerendering SPA content pages to enable AI agent access | Netlify Developers Identify image optimization opportunities with Netlify Observability | Netlify Developers Fix top 404 page not found errors with Netlify Observability | Netlify Developers Introducing AI Gateway: built-in AI model access on Netlify | Netlify Developers Introducing Observability: your project insights on Netlify | Netlify Developers From first publish to first update with AI agents | Netlify Developers How to use Agent Runners on Netlify | Netlify Developers Add forms to your project with AI + Netlify | Netlify Developers Track Real User Metrics | Netlify Developers Lighthouse performance scores on Netlify | Netlify Developers Review your AI project before you ship | Netlify Developers Using environment variables in AI Projects on Netlify | Netlify Developers Build prototypes and MVPs fast with AI + Netlify | Netlify Developers Pause auto-publishing on Netlify | Netlify Developers Run serverless functions, storage, and more natively in Nuxt dev | Netlify Developers Netlify Office Hours: The AX Arcade challenge | Netlify Developers Netlify Office Hours: Prompting with style | Netlify Developers Netlify Office Hours: RAG Apps with OpenAI + Netlify DB | Netlify Developers How to build a RAG application with Neon, Netlify & OpenAI | Netlify Developers Netlify Office Hours: Netlify DB (powered by Neon) | Netlify Developers Netlify Office Hours: Netlify MCP Server | Netlify Developers Netlify Office Hours: Netlify Vite Plugin | Netlify Developers Building MCPs with Netlify | Netlify Developers Deploying sites from your AI tool | Netlify Developers Build a context driven chat bot with Netlify Blob and OpenAI | Netlify Developers Simplify deployments with Netlify’s branch-matching environment variables | Netlify Developers Deploy a Lovable site to Netlify | Netlify Developers
Adding your domain using Netlify API | Netlify Developers
2025-03-31 · via Netlify Developers

Netlify exposes the Netlify REST API for different use cases to replicate the UI experience with code. Let’s explore a few ways to add a domain to your account and site programmatically.

#Add a custom domain API example

To add a custom domain to your site you have to make a PATCH request to the updateSite endpoint with a payload that includes the custom_domain parameter and its value.

Make sure you are authorized to make this request as a Developer or Owner on the Netlify team account.

curl example:

curl -X PATCH "https://api.netlify.com/api/v1/sites/{site_id}" \

-H "Authorization: Bearer YOUR_TOKEN_HERE" \

-H "Content-Type: application/json" \

-d '{

"custom_domain": "your-domain.com"

}'

#Add a subdomain API example

Adding a subdomain follows a similar process. You just have to provide the value of the subdomain in your payload.

If you haven’t added an apex domain to Netlify DNS, your domain will have to pass additional verification. Verification is important. Once a subdomain is added to Netlify DNS, no other account can add that subdomain. So to prevent domains takeovers, Netlify requires verification.

Before adding a subdomain to the site, add host netlify-challenge.your-domain.com with any value to your DNS TXT record. Netlify will verify the host netlify-challenge.your-domain.com value before adding your subdomain to the site. So, when passing custom_domain as part of the site update endpoint, you have to provide the parameter txt_record_value as well with the same value as you’ve added to your DNS record for host netlify-challenge.your-domain.com.

curl example:

curl -X PATCH "https://api.netlify.com/api/v1/sites/{site_id}" \

-H "Authorization: Bearer YOUR_TOKEN_HERE" \

-H "Content-Type: application/json" \

-d '{

"custom_domain": "subdomain.your-domain.com",

"txt_record_value": "value"

}'

To finish up the process of adding a domain you have to either use Netlify DNS or provide your custom SSL certificate.