Publish survey draft to live
const url = 'https://app.surveyrock.com/api/v1/surveys/example/publish';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"treatAsNewQuestionIds":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Survey ID
Request Body
Section titled “Request Body”Optional publish options
object
Question IDs to treat as new (break data continuity)
Examplegenerated
{ "treatAsNewQuestionIds": [ "example" ]}Responses
Section titled “Responses”Survey published successfully
object
object
Standard response metadata
object
Response timestamp in ISO 8601 format
API version
Unique request identifier
Example
{ "success": true, "data": { "versionNumber": 1 }, "meta": { "version": "3.0" }}Survey not found
Standard error response format
object
object
Stable, snake_case domain code – see ApiErrorHandler::EXCEPTION_MAP and DomainException
Human-readable error message
Imperative recovery hint for this domain code – see ApiErrorHandler::DOMAIN_CODE_SUGGESTIONS
Whether retrying the identical request might succeed without any change on the caller’s end
Additional, code-specific error details
object
Standard response metadata
object
Response timestamp in ISO 8601 format
API version
Unique request identifier
Example
{ "success": false, "error": { "code": "survey_not_found" }, "meta": { "version": "3.0" }}Conflict - survey is currently being published
Standard error response format
object
object
Stable, snake_case domain code – see ApiErrorHandler::EXCEPTION_MAP and DomainException
Human-readable error message
Imperative recovery hint for this domain code – see ApiErrorHandler::DOMAIN_CODE_SUGGESTIONS
Whether retrying the identical request might succeed without any change on the caller’s end
Additional, code-specific error details
object
Standard response metadata
object
Response timestamp in ISO 8601 format
API version
Unique request identifier
Example
{ "success": false, "error": { "code": "survey_not_found" }, "meta": { "version": "3.0" }}Validation failed - survey cannot be published
Validation error response with field-specific errors
object
object
Field-specific validation errors
object
Standard response metadata
object
Response timestamp in ISO 8601 format
API version
Unique request identifier
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" }}