Skip to content

Publish survey draft to live

POST
/surveys/{id}/publish
curl --request POST \
--url https://app.surveyrock.com/api/v1/surveys/example/publish \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "treatAsNewQuestionIds": [ "example" ] }'

Promotes the current draft state to live, creating a new version. Validates the survey before publishing and acquires a lock to prevent concurrent publishes.

id
required
string

Survey ID

Optional publish options

Media typeapplication/json
object
treatAsNewQuestionIds

Question IDs to treat as new (break data continuity)

Array<string>
Examplegenerated
{
"treatAsNewQuestionIds": [
"example"
]
}

Survey published successfully

Media typeapplication/json
object
success
boolean
data
object
versionNumber
integer
publishedAt
string format: date-time
versionId
string
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
Example
{
"success": true,
"data": {
"versionNumber": 1
},
"meta": {
"version": "3.0"
}
}

Survey not found

Media typeapplication/json

Standard error response format

object
success
boolean
error
object
code

Stable, snake_case domain code – see ApiErrorHandler::EXCEPTION_MAP and DomainException

string
message

Human-readable error message

string
suggestion

Imperative recovery hint for this domain code – see ApiErrorHandler::DOMAIN_CODE_SUGGESTIONS

string
retryable

Whether retrying the identical request might succeed without any change on the caller’s end

boolean
details

Additional, code-specific error details

object
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
Example
{
"success": false,
"error": {
"code": "survey_not_found"
},
"meta": {
"version": "3.0"
}
}

Conflict - survey is currently being published

Media typeapplication/json

Standard error response format

object
success
boolean
error
object
code

Stable, snake_case domain code – see ApiErrorHandler::EXCEPTION_MAP and DomainException

string
message

Human-readable error message

string
suggestion

Imperative recovery hint for this domain code – see ApiErrorHandler::DOMAIN_CODE_SUGGESTIONS

string
retryable

Whether retrying the identical request might succeed without any change on the caller’s end

boolean
details

Additional, code-specific error details

object
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
Example
{
"success": false,
"error": {
"code": "survey_not_found"
},
"meta": {
"version": "3.0"
}
}

Validation failed - survey cannot be published

Media typeapplication/json

Validation error response with field-specific errors

object
success
boolean
error
object
code
string
message
string
suggestion
string
retryable
boolean
details

Field-specific validation errors

object
key
additional properties
Array<string>
meta

Standard response metadata

object
timestamp

Response timestamp in ISO 8601 format

string format: date-time
version

API version

string
requestId

Unique request identifier

string
Example
{
"success": false,
"error": {
"code": "validation_failed",
"message": "Validation failed",
"suggestion": "Fix the fields listed in details and re-submit.",
"retryable": false
},
"meta": {
"version": "3.0"
}
}