R
Railway15mo ago
pikachu

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
Percy15mo ago
Project ID: 63b7280d-bfb7-499f-89d2-73fd8e2a081b
pikachu
pikachuOP15mo ago
63b7280d-bfb7-499f-89d2-73fd8e2a081b
Brody
Brody15mo ago
well you can only generate a single railway provided domain do you mean to ask how to add custom domains to a service?
pikachu
pikachuOP15mo 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
Brody15mo ago
well I don't know what you mean by dynamically, you need to own the domain you are adding
pikachu
pikachuOP15mo 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
Brody15mo 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
pikachu
pikachuOP15mo ago
yes! that would be amazing right now it's kind of manual (on our end)
Brody
Brody15mo ago
sure that can be done, are you on the pro plan by chance?
pikachu
pikachuOP15mo ago
not yet - but will upgrade as necessary!
Brody
Brody15mo 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
pikachu
pikachuOP15mo ago
gotcha we'll upgrade tmrw thanks for lmk just upgraded! appreciate the help - glad to know it's possible!
Brody
Brody15mo ago
ill get you that mutation now
Solution
Brody
Brody15mo 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
Brody15mo ago
ive been told there is no limit on the amount of custom domains you can create on a service
pikachu
pikachuOP15mo ago
awesome, this is super helpful, appreciate it a ton!!
Brody
Brody15mo ago
no problem!
Want results from more Discord servers?
Add your server