R
Railway9mo ago
kevin

anyone successfully manage to use the public API to dynamically generate a custom domain?

just want to check if anyone has been able to and if they can share their graphql query https://docs.railway.app/reference/public-api#examples otherwise i'm planning to try it later in the week and will report back thanks!
Railway Docs
Public API Reference | Railway Docs
Documentation for Railway
Solution:
```graphql mutation customDomainCreate($input: CustomDomainCreateInput!) { customDomainCreate(input: $input) { id domain...
Jump to solution
17 Replies
Percy
Percy9mo ago
Project ID: 63b7280d-bfb7-499f-89d2-73fd8e2a081b
kevin
kevin9mo ago
63b7280d-bfb7-499f-89d2-73fd8e2a081b
Brody
Brody9mo ago
well you can only generate a single railway provided domain do you mean to ask how to add custom domains to a service?
kevin
kevin9mo ago
ah i meant like a custom domain - cname + target being able to generate dynamically would be awesome since right now we have clients who use our subdomains e.g. myapp.kalder.app
Brody
Brody9mo ago
well I don't know what you mean by dynamically, you need to own the domain you are adding
kevin
kevin9mo ago
and would be cool if they can point their own custom domains, in a self-serve way from our app like if we can just give them the cname + target (from railway api) and tell them to do it themselves in cloudflare or wherever
Brody
Brody9mo ago
ah okay so if user has domain.xyz you want to add that domain to the railway service and get back the cname to give to the client
kevin
kevin9mo ago
yes! that would be amazing right now it's kind of manual (on our end)
Brody
Brody9mo ago
sure that can be done, are you on the pro plan by chance?
kevin
kevin9mo ago
not yet - but will upgrade as necessary!
Brody
Brody9mo ago
generally once a project that hosted with railway gains a userbase it would be required to upgrade to pro but just stating that, you can make this mutation on any plan type
kevin
kevin9mo ago
gotcha we'll upgrade tmrw thanks for lmk just upgraded! appreciate the help - glad to know it's possible!
Brody
Brody9mo ago
ill get you that mutation now
Solution
Brody
Brody9mo ago
mutation customDomainCreate($input: CustomDomainCreateInput!) {
customDomainCreate(input: $input) {
id
domain
createdAt
updatedAt
serviceId
environmentId
status {
dnsRecords {
hostlabel
fqdn
recordType
requiredValue
currentValue
status
zone
purpose
}
cdnProvider
certificates {
issuedAt
expiresAt
domainNames
fingerprintSha256
keyType
}
certificateStatus
}
}
}
mutation customDomainCreate($input: CustomDomainCreateInput!) {
customDomainCreate(input: $input) {
id
domain
createdAt
updatedAt
serviceId
environmentId
status {
dnsRecords {
hostlabel
fqdn
recordType
requiredValue
currentValue
status
zone
purpose
}
cdnProvider
certificates {
issuedAt
expiresAt
domainNames
fingerprintSha256
keyType
}
certificateStatus
}
}
}
{
"input": {
"domain": "",
"environmentId": "",
"serviceId": ""
}
}
{
"input": {
"domain": "",
"environmentId": "",
"serviceId": ""
}
}
you may also want this query too
query customDomainAvailable($domain: String!) {
customDomainAvailable(domain: $domain) {
available
message
}
}
query customDomainAvailable($domain: String!) {
customDomainAvailable(domain: $domain) {
available
message
}
}
{
"domain": ""
}
{
"domain": ""
}
Brody
Brody9mo ago
ive been told there is no limit on the amount of custom domains you can create on a service
kevin
kevin9mo ago
awesome, this is super helpful, appreciate it a ton!!
Brody
Brody9mo ago
no problem!