diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml
index 80ab535e19..d74f7911f7 100644
--- a/.buildkite/pipeline.yml
+++ b/.buildkite/pipeline.yml
@@ -29,7 +29,7 @@ steps:
     env:
       RUBY_VERSION: "{{ matrix.ruby }}"
       STACK_VERSION: 9.0.0-SNAPSHOT
-      ES_YAML_TESTS_BRANCH: main
+      ES_YAML_TESTS_BRANCH: '9.0'
       TRANSPORT_VERSION: "{{ matrix.transport }}"
       RUBY_SOURCE: "{{ matrix.ruby_source }}"
       TEST_SUITE: "platinum"
@@ -62,7 +62,7 @@ steps:
       RUBY_VERSION: "3.4"
       RUBY_SOURCE: "ruby"
       TEST_SUITE: serverless
-      ES_YAML_TESTS_BRANCH: main
+      ES_YAML_TESTS_BRANCH: '9.0'
       QUIET: false
     command: ./.buildkite/run-yaml-tests.sh
     artifact_paths: "elasticsearch-api/tmp/*"
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
index 164ef9da0b..95cfab0144 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/bulk.rb
@@ -163,7 +163,9 @@ def bulk(arguments = {})
                     body
                   end
 
-        headers.merge!('Content-Type' => 'application/x-ndjson')
+        headers.merge!({
+                         'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+                       })
         Elasticsearch::API::Response.new(
           perform_request(method, path, params, payload, headers, request_opts)
         )
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb
index 402c61a035..10f6a4daa4 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/fleet/msearch.rb
@@ -97,7 +97,9 @@ def msearch(arguments = {})
             payload = body
           end
 
-          headers.merge!('Content-Type' => 'application/x-ndjson')
+          headers.merge!({
+                           'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+                         })
           Elasticsearch::API::Response.new(
             perform_request(method, path, params, payload, headers, request_opts)
           )
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb
index 120a7fb03f..1939435445 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb
@@ -103,7 +103,9 @@ def msearch(arguments = {})
           payload = body
         end
 
-        headers.merge!('Content-Type' => 'application/x-ndjson')
+        headers.merge!({
+                         'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+                       })
         Elasticsearch::API::Response.new(
           perform_request(method, path, params, payload, headers, request_opts)
         )
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb
index b0c9e53385..ad37661b9e 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/msearch_template.rb
@@ -81,7 +81,9 @@ def msearch_template(arguments = {})
           payload = body
         end
 
-        headers.merge!('Content-Type' => 'application/x-ndjson')
+        headers.merge!({
+                         'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+                       })
         Elasticsearch::API::Response.new(
           perform_request(method, path, params, payload, headers, request_opts)
         )
diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb
index e49a881fd0..496d4a0b84 100644
--- a/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb
+++ b/elasticsearch-api/lib/elasticsearch/api/actions/text_structure/find_structure.rb
@@ -136,7 +136,9 @@ def find_structure(arguments = {})
                       body
                     end
 
-          headers.merge!('Content-Type' => 'application/x-ndjson')
+          headers.merge!({
+                           'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+                         })
           Elasticsearch::API::Response.new(
             perform_request(method, path, params, payload, headers, request_opts)
           )
diff --git a/elasticsearch-api/spec/unit/actions/bulk_spec.rb b/elasticsearch-api/spec/unit/actions/bulk_spec.rb
index 0d18d0ee9a..25906f11c7 100644
--- a/elasticsearch-api/spec/unit/actions/bulk_spec.rb
+++ b/elasticsearch-api/spec/unit/actions/bulk_spec.rb
@@ -25,11 +25,16 @@
         params,
         body,
         headers,
-        {:endpoint=>"bulk"}
+        { endpoint: 'bulk' }
     ]
   end
 
-  let(:headers) { { 'Content-Type' => 'application/x-ndjson' } }
+  let(:headers) {
+    {
+      'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+    }
+  }
+
   let(:params) { {} }
   let(:url) { '_bulk' }
   let(:body) { '' }
diff --git a/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb b/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb
index af44de93e8..40ef5f6584 100644
--- a/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb
+++ b/elasticsearch-api/spec/unit/actions/fleet/msearch_spec.rb
@@ -24,11 +24,17 @@
       '_fleet/_fleet_msearch',
       {},
       {},
-      { 'Content-Type' => 'application/x-ndjson' },
+      headers,
       { endpoint: 'fleet.msearch' }
     ]
   end
 
+  let(:headers) {
+    {
+      'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+    }
+  }
+
   it 'performs the request' do
     expect(client_double.fleet.msearch(body: {})).to be_a Elasticsearch::API::Response
   end
diff --git a/elasticsearch-api/spec/unit/actions/msearch_spec.rb b/elasticsearch-api/spec/unit/actions/msearch_spec.rb
index 3c56a6a46c..a7b576e02c 100644
--- a/elasticsearch-api/spec/unit/actions/msearch_spec.rb
+++ b/elasticsearch-api/spec/unit/actions/msearch_spec.rb
@@ -41,9 +41,11 @@
     {}
   end
 
-  let(:headers) do
-    { 'Content-Type' => 'application/x-ndjson' }
-  end
+  let(:headers) {
+    {
+      'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+    }
+  }
 
   let(:client) do
     Class.new { include Elasticsearch::API }.new
@@ -89,7 +91,6 @@
   end
 
   context 'when an index is specified' do
-
     let(:url) do
       'foo/_msearch'
     end
@@ -115,7 +116,6 @@
   end
 
   context 'when multiple indices are specified' do
-
     let(:url) do
       'foo,bar/_msearch'
     end
diff --git a/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb b/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb
index 5ec1af4dbc..8b30d7d189 100644
--- a/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb
+++ b/elasticsearch-api/spec/unit/actions/msearch_template_spec.rb
@@ -37,16 +37,17 @@
     {}
   end
 
-  let(:headers) do
-    { 'Content-Type' => 'application/x-ndjson' }
-  end
+  let(:headers) {
+    {
+      'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+    }
+  }
 
   let(:url) do
     '_msearch/template'
   end
 
   context 'when a body is provided as a document' do
-
     let(:body) do
       <<-PAYLOAD.gsub(/^\s+/, '')
             {"index":"foo"}
@@ -67,7 +68,6 @@
   end
 
   context 'when a body is provided as a string' do
-
     let(:body) do
       %Q|{"foo":"bar"}\n{"moo":"lam"}|
     end
@@ -78,7 +78,6 @@
   end
 
   context 'when an index is provided' do
-
     let(:url) do
       'foo/_msearch/template'
     end
diff --git a/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb b/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb
index e6d18a9ad7..cd94e76348 100644
--- a/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb
+++ b/elasticsearch-api/spec/unit/actions/text_structure/find_structure_spec.rb
@@ -24,11 +24,17 @@
       '_text_structure/find_structure',
       {},
       {},
-      { 'Content-Type' => 'application/x-ndjson' },
+      headers,
       { endpoint: 'text_structure.find_structure' }
     ]
   end
 
+  let(:headers) {
+    {
+      'Content-Type' => 'application/vnd.elasticsearch+x-ndjson; compatible-with=9'
+    }
+  }
+
   it 'performs the request' do
     expect(client_double.text_structure.find_structure(body: {})).to be_a Elasticsearch::API::Response
   end
diff --git a/elasticsearch-api/spec/yaml-test-runner/run.rb b/elasticsearch-api/spec/yaml-test-runner/run.rb
index 81f0b5743f..9849bf1da5 100644
--- a/elasticsearch-api/spec/yaml-test-runner/run.rb
+++ b/elasticsearch-api/spec/yaml-test-runner/run.rb
@@ -81,7 +81,7 @@ def serverless?
 
 # If we're running in a release branch, download the corresponding branch for tests
 current_branch = `git rev-parse --abbrev-ref HEAD`.strip
-branch = current_branch.match(/[0-9]\.[0-9]+/)&.[](0) || ENV['ES_YAML_TESTS_BRANCH'] || nil
+branch = ENV['ES_YAML_TESTS_BRANCH'] || current_branch.match(/[0-9]\.[0-9]+/)&.[](0) || nil
 Elasticsearch::Tests::Downloader::run(tests_path, branch)
 
 runner = Elasticsearch::Tests::TestRunner.new(CLIENT, tests_path, logger)
diff --git a/elasticsearch/lib/elasticsearch.rb b/elasticsearch/lib/elasticsearch.rb
index 77b2ba0ffc..3e55285ad9 100644
--- a/elasticsearch/lib/elasticsearch.rb
+++ b/elasticsearch/lib/elasticsearch.rb
@@ -52,6 +52,7 @@ def initialize(arguments = {}, &block)
       api_key(arguments) if arguments[:api_key]
       setup_cloud(arguments) if arguments[:cloud_id]
       set_user_agent!(arguments) unless sent_user_agent?(arguments)
+      set_content_type!(arguments)
       @transport = Elastic::Transport::Client.new(arguments, &block)
     end
 
@@ -175,9 +176,21 @@ def set_user_agent!(arguments)
       if RbConfig::CONFIG && RbConfig::CONFIG['host_os']
         user_agent << "#{RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase} #{RbConfig::CONFIG['target_cpu']}"
       end
+      set_header({ user_agent: user_agent.join('; ') }, arguments)
+    end
+
+    def set_content_type!(arguments)
+      headers = {
+        'content-type' => 'application/vnd.elasticsearch+json; compatible-with=9',
+        'accept' => 'application/vnd.elasticsearch+json; compatible-with=9'
+      }
+      set_header(headers, arguments)
+    end
+
+    def set_header(header, arguments)
       arguments[:transport_options] ||= {}
       arguments[:transport_options][:headers] ||= {}
-      arguments[:transport_options][:headers].merge!({ user_agent: user_agent.join('; ') })
+      arguments[:transport_options][:headers].merge!(header)
     end
   end